Skip to content

Instantly share code, notes, and snippets.

@Overdrivr
Created May 9, 2016 21:18
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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