Why am I missing PYTHONPATH?

2.8k Views Asked by At

I was trying to list installed packages in newly installed Xubuntu 12.04 with:

for d in `echo "${PYTHONPATH}" | tr ':' '\n'`; do ls "${d}"; done

but after I got nothing I figured out that I am missing PYTHONPATH. Then I tried it on my Xubuntu 14.04 and I got the same. I tried to find out why I am missing this variable, but only changing it is mentioned everywhere. Thanks

1

There are 1 best solutions below

0
geckon On BEST ANSWER

The $PYTHONPATH variable is typically empty unless you define it. You can define the variable for example in your ~/.profile or ~/.bashrc files.

If you want to see what paths your Python uses, you can get a list of them like this in a script or in the interactive shell:

import sys
print(sys.path)

If you want to retrieve them in a regular shell (e.g. BASH), you can take an advantage of Python's -c option:

python -c 'import sys; print(sys.path)'