加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – AttributeError:module’numpy’没有属性’__versi

发布时间:2020-12-16 22:31:30 所属栏目:Python 来源:网络整理
导读:我今天更新了我的电脑,当我尝试导入pandas时收到以下错误消息: import pandas as pd AttributeError: module 'numpy' has no attribute '__version__' 我尝试过以下链接中的建议: AttributeError: module object has no attribute __version__ AttributeEr

我今天更新了我的电脑,当我尝试导入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:Usersj267156AppDataLocalContinuumanaconda2envssf35libsite-packagesnumpy'])

    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足以恢复功能,然后在环境中固定版本.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读