3

What is the $PYTHONPATH variable, and what's the significance in setting it?

Also, if I want to know the content of my current pythonpath, how do I find that out?

Totem
7,3795 gold badges43 silver badges67 bronze badges
asked Apr 30, 2016 at 17:14

2 Answers 2

2

As already answered PYTHONPATH is the search path used by python to find modules when you ''import' them.
Echoing $PYTHONPATH is only useful if you have set it.
However in python itself you can list out what it thinks it is.

$ python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python3/dist-packages']
>>> 
answered Jun 23, 2016 at 18:37
Sign up to request clarification or add additional context in comments.

Comments

0

PYTHONPATH is the default search path for importing modules. If you use bash, you could type echo $PYTHONPATH to look at it.

answered Apr 30, 2016 at 17:19

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.