0 votes
1 view
in Python by (47.8k points)

How do I find out which directories are listed in my system’s PYTHONPATH variable, from within a Python script (or the interactive shell)?

1 Answer

0 votes
by (107k points)

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 os

try:

user_paths = os.environ['PYTHONPATH'].split(os.pathsep)

except KeyError:

user_paths = []

Related questions

0 votes
1 answer
+2 votes
3 answers
0 votes
1 answer
asked Aug 1, 2019 in Python by Sammy (47.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...