Python library path

In ruby, the library path is specified in $: in perl it in @INC - how do you get the list of paths that Python looks for modules when importing?

+44
python
Sep 25 '08 at 18:23
source share
3 answers

I think you are looking for sys.path

 import sys print (sys.path) 
+59
Sep 25 '08 at 18:25
source share

You can also make additions to this path with the PYTHONPATH environment variable at run time, in addition to:

 import sys sys.path.append('/home/user/python-libs') 
+61
Sep 25 '08 at 19:02
source share
 import sys sys.path 
+8
Sep 25 '08 at 18:25
source share



All Articles