Back
How do I find out which directories are listed in my system’s PYTHONPATH variable, from within a Python script (or the interactive shell)?
For finding out your python path using python you can use the sys.path that might include items that aren't specifically in your PYTHONPATH environment variable. You can use the below-mentioned code:-
import ostry:user_paths = os.environ['PYTHONPATH'].split(os.pathsep)except KeyError:user_paths = []
import os
try:
user_paths = os.environ['PYTHONPATH'].split(os.pathsep)
except KeyError:
user_paths = []
31k questions
32.4k answers
500 comments
693 users