How do I find out my python path using python?

Paul D. Waite picture Paul D. Waite · Sep 29, 2009 · Viewed 631.3k times · Source

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

Answer

Vanuan picture Vanuan · Nov 1, 2012

You would probably also want this:

import sys
print(sys.path)

Or as a one liner from the terminal:

python -c "import sys; print('\n'.join(sys.path))"

Caveat: If you have multiple versions of Python installed you should use a corresponding command python2 or python3.