我的 pandas 包没有被导入。 当我尝试使用命令检查是否有 Pandas 时
python -c "import pandas"
它显示一些奇怪的错误,例如
<module 'numpy' from 'numpy.pyc'>
'module' object has no attribute 'dtype'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
File "numpy.pxd", line 157, in init pandas.hashtable (pandas/hashtable.c:21706)
AttributeError: 'module' object has no attribute 'dtype'
最佳答案
您有一个名为 numpy.py
的本地文件,该文件正在导入,而不是全局安装的 NumPy 项目:
<module 'numpy' from 'numpy.pyc'>
删除或重命名该文件,并删除其旁边关联的 numpy.pyc 文件。您的本地文件没有名称 dtype
,只有 site-packages
中安装的 numpy
package 具有名称,但它每次第一次找到您的文件时都无法加载。
关于python - Python-2.7 的模块在明确安装后未导入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36601817/