Skip to content

Instantly share code, notes, and snippets.

@Overdrivr
Created May 9, 2016 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Overdrivr/52721132b9f40635cd496d7c988ae583 to your computer and use it in GitHub Desktop.
Save Overdrivr/52721132b9f40635cd496d7c988ae583 to your computer and use it in GitHub Desktop.
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