我今天更新了我的电脑,当我尝试导入pandas时收到以下错误消息:
import pandas as pd
AttributeError: module 'numpy' has no attribute '__version__'
我尝试过以下链接中的建议:
> AttributeError: ‘module’ object has no attribute ‘__version__’
> AttributeError: ‘module’ object has no attribute ‘__version__’
除了numpy包之外,我没有任何文件名numpy.py.
我在Windows 10中运行anaconda2,并创建了一个python 3.5虚拟环境.
以下是完整的错误消息:
Python 3.5.5 | packaged by conda-forge | (default,Apr 6 2018,16:03:44) [MSC v.1900 64 bit (AMD64)] on win32
Type "help","copyright","credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
File "
编辑:执行以下命令会出错
import numpy
print(numpy.__file__)
AttributeError: module 'numpy' has no attribute '__file__'
print(numpy.version.version)
AttributeError: module 'numpy' has no attribute 'version'
Edit2:执行以下命令会给我以下错误:
import numpy as np
np.zeros(5)
#AttributeError: module 'numpy' has no attribute 'zeros'
vars(np).keys()
#dict_keys(['__name__','__package__','__spec__','__loader__','__doc__','__path__'])
Edit3:以下命令导致以下输出:
import numpy as np
In [7]: np.__path__
Out[7]: _NamespacePath(['C:\\Users\\j267156\\AppData\\Local\\Continuum\\anaconda2\\envs\\sf35\\lib\\site-packages\\numpy'])
In [8]: np.__loader__
Out[8]: <_frozen_importlib_external._NamespaceLoader at 0x2033a3c8080>
最佳答案
在conda选择将numpy从1.13.3更新到1.14.3之后,就遇到了这个问题.通过http://blog.rtwilson.com/conda-revisions-letting-you-rollback-to-a-previous-version-of-your-environment/中的过程恢复numpy足以恢复功能,然后在环境中固定版本.
原文链接:https://www.f2er.com/python/438875.html