Created
May 9, 2016 21:18
-
-
Save Overdrivr/52721132b9f40635cd496d7c988ae583 to your computer and use it in GitHub Desktop.
Display all python importable paths
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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