Skip to content

Instantly share code, notes, and snippets.

@Overdrivr
Created May 9, 2016
Embed
What would you like to do?
Display all python importable paths
import sys
import os
from colorama import init
from colorama import Fore, Back, Style
init()
def testEquals(p,l):
for i in l:
if os.path.normpath(p) == os.path.normpath(i):
return True
return False
try:
user_paths = os.environ['PYTHONPATH'].split(os.pathsep)
except KeyError:
user_paths = []
print(">> sys.path : all importable paths. " + Fore.GREEN + "(from PYTHONPATH)")
for p in sys.path:
p = os.path.normpath(p)
if testEquals(p,user_paths):
print(Fore.GREEN + p)
else:
print(Fore.BLUE + p)
print(Style.RESET_ALL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment