Does `anaconda` create a separate PYTHONPATH variable for each new environment?

后端 未结 2 1540
萌比男神i
萌比男神i 2020-11-27 02:35

I am starting to work with the Python Anaconda distribution from Continuum.io to do scipy work.
I have been able to get Anaconda up and running, but I canno

2条回答
  •  情歌与酒
    2020-11-27 03:10

    Anaconda does not use the PYTHONPATH. One should however note that if the PYTHONPATH is set it could be used to load a library that is not in the anaconda environment. That is why before activating an environment it might be good to do a

    unset PYTHONPATH
    

    For instance this PYTHONPATH points to an incorrect pandas lib:

    export PYTHONPATH=/home/john/share/usr/anaconda/lib/python
    source activate anaconda-2.7
    python
    >>>> import pandas as pd
    /home/john/share/usr/lib/python/pandas-0.12.0-py2.7-linux-x86_64.egg/pandas/hashtable.so: undefined symbol: PyUnicodeUCS2_DecodeUTF8
    Traceback (most recent call last):
      File "", line 1, in 
      File "/home/john/share/usr/lib/python/pandas-0.12.0-py2.7-linux-x86_64.egg/pandas/__init__.py", line 6, in 
        from . import hashtable, tslib, lib
    ImportError: /home/john/share/usr/lib/python/pandas-0.12.0-py2.7-linux-x86_64.egg/pandas/hashtable.so: undefined symbol: PyUnicodeUCS2_DecodeUTF8
    

    unsetting the PYTHONPATH prevents the wrong pandas lib from being loaded:

    unset PYTHONPATH
    source activate anaconda-2.7
    python
    >>>> import pandas as pd
    >>>>
    

提交回复
热议问题