简体   繁体   中英

How to change python module path

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM