Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k 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 (106k 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
0 votes
1 answer
asked Aug 1, 2019 in Python by Sammy (47.6k points)

31k questions

32.4k answers

500 comments

693 users

Browse Categories

...