我使用的是Pandas版本0.16.1并且它工作正常但我想将Pandas更新到版本0.16.2所以我卸载它并使用
重新安装它pip uninstall pandas
pip install pandas
安装似乎工作正常。但是,当我尝试导入pandas
时import pandas
我收到错误:
Traceback (most recent call last):
File "path_to_python/python3.4/site-packages/pandas/__init__.py", line 7, in <module>
from pandas import hashtable, tslib, lib
ImportError: path_to_python/python3.4/site-packages/pandas/hashtable.cpython-34m.so: undefined symbol: pyobject_cmp
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "path_to_python/python3.4/site-packages/pandas/__init__.py", line 13, in <module>
"extensions first.".format(module))
ImportError: C extension: path_to_python/python3.4/site-packages/pandas/hashtable.cpython-34m.so:
undefined symbol: pyobject_cmp not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
但是:
cd path_to_python/python3.4/site-packages/pandas/
python setup.py build_ext --inplace
无法正常工作,因为没有找到setup.py。错误是:
Fatal Python error: Py_Initialize: can't initialize sys standard streams
AttributeError: 'module' object has no attribute 'OpenWrapper'
Aborted (core dumped)
对于可能出现的问题的任何建议或见解将不胜感激!
更新:
我尝试通过下载软件包从源代码安装它:
python setup.py install
python setup.py build_ext --inplace
这次第二个命令产生了大量输出并成功完成。但是,当我尝试导入pandas时,我仍然遇到同样的错误
答案 0 :(得分:1)
如果有人感兴趣,我无法让pandas安装pip,但我转而使用miniconda并安装它并且它工作正常。
答案 1 :(得分:1)
由于编译器标志,我无法使用clang构建pandas。默认情况下使用C99
模型进行Clang会导致对pandas中使用的inline
代码进行不正确的编译。
所以在我的情况下CFLAGS=-fgnu89-inline pip install pandas --global-option=build_ext
做了伎俩。