[Tutor] Q on path information

Ebba Cecilia Ovesdotter Alm ebbaalm at uiuc.edu
Thu May 25 19:58:54 CEST 2006


I have 2 questions I'm curious about (BTW, I use the default
python installation as delivered with Linux SuSe 10.0)

(1) How can I print the path to the python I'm using and where
it imports built-in modules?

python.sys returns (i probably want 64bit, so this seems ok):
/usr/lib/python24.zip
/usr/lib64/python2.4
/usr/lib64/python2.4/plat-linux2
/usr/lib64/python2.4/lib-tk
/usr/lib64/python2.4/lib-dynload
/usr/lib64/python2.4/site-packages
/usr/lib64/python2.4/site-packages/Numeric
/usr/lib64/python2.4/site-packages/PIL

But, "which python" in the shell returns 
/usr/bin/python

And "whereis python" returns 
python: /usr/bin/python /usr/bin/python2.4 /usr/lib/python2.4
/usr/include/python /usr/include/python2.4
/usr/share/man/man1/python.1.gz

Does this mean I am using the python executable in
"/usr/bin/python/" but it then looks for built-in modules in 
"/usr/lib64/python2.4/"?

(2) A clarification question: PYTHONPATH is not needed as long
as one just imports built-in modules (such as re or sys) or
own modules from the same directory as the importing script,
right? For example, running "python foo.py" on the command
line, where foo.py imports a module "foo2.py" from the same
directory, the current directory is inferred automatically, right?

Thanks!

E. Cecilia Ovesdotter Alm
Graduate student/Dept. of Linguistics, UIUC
http://www.linguistics.uiuc.edu/ebbaalm/
Office: 2013 Beckman
Phone: (217) 721-7387



More information about the Tutor mailing list