Anaconda 不使用PYTHONPATH
. 但是应该注意,如果PYTHONPATH
设置了它,它可以用于加载不在 anaconda 环境中的库。这就是为什么在激活环境之前做一个
unset PYTHONPATH
例如,这个 PYTHONPATH 指向一个不正确的 pandas 库:
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 "<stdin>", line 1, in <module>
File "/home/john/share/usr/lib/python/pandas-0.12.0-py2.7-linux-x86_64.egg/pandas/__init__.py", line 6, in <module>
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
取消设置PYTHONPATH
可以防止加载错误的熊猫库:
unset PYTHONPATH
source activate anaconda-2.7
python
>>>> import pandas as pd
>>>>