简体   繁体   English

肯定已安装,但未导入Python-2.7模块

[英]A module of Python-2.7 not getting imported when it is definitely installed

My pandas package is not getting imported. 我的熊猫包装没有被进口。 When I try to check if I have pandas using the command 当我尝试使用以下命令检查我是否有大熊猫时

python -c "import pandas"

It shows some strange error like 它显示了一些奇怪的错误,例如

<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'

You have a local file named numpy.py which is being imported instead of the globally installed NumPy project: 您将导入一个名为numpy.py本地文件,而不是全局安装的NumPy项目:

<module 'numpy' from 'numpy.pyc'>

Remove or rename that file and delete the associated numpy.pyc file next to it. 删除或重命名该文件,然后删除该文件旁边的关联numpy.pyc文件。 Your local file has no name dtype , only the numpy package installed in your site-packages does, but it can't be loaded when your file is found first every time. 你的本地文件没有名称dtype ,只有numpy 软件包安装在您的site-packages呢,但是当你的文件第一次每一次发现它无法加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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