0
votes

I install a python2.7.6 locally, and there is another 2.7.6 installed on cluster publicly.

Then I use my local python to install a pip but when I 'pip list', it returns:

$ pip list Traceback (most recent call last): File "/home/zengh/.local/bin/pip", line 7, in from pip import main File "/home/zengh/.local/lib/python2.7/site-packages/pip/init.py", line 13, in from pip.utils import get_installed_distributions, get_prog File "/home/zengh/.local/lib/python2.7/site-packages/pip/utils/init.py", line 5, in import locale File "/home/software/rhel6/python/2.7.6/lib/python2.7/locale.py", line 18, in import operator ImportError: /home/software/rhel6/python/2.7.6/lib/python2.7/lib-dynload/operator.so: undefined symbol: _PyUnicodeUCS2_AsDefaultEncodedString

Obviously it calls the locale.py on the cluster while my PYTHONPATH only contains my local python's path. How can I make it call the

/.local/python2.7.6/lib/python2.7/locale.py?

Thanks

1
How did your get your local python installed? - piglei
The solution might also be: Do not install a second Python2.7. What for did you install a second Python2.7? Maybe there is an other solution to your original problem. - User
It is because 'undefined symbol: PyUnicodeUCS4_Decode' appeared when I run the python from original python on the cluster. So I install it as /configure --prefix=/home/username/.local/python2.7.6 --enable-shared -enable-unicode=ucs4 $make;make install - Huayi Zeng

1 Answers

0
votes

Depends on whether you want to set it from within a script or from os.

From script:

    import sys
    sys.path.append('additional dir')

From os:

    export PYTHONPATH=somewhere