pandas AttributeError: 模块 'numpy' 没有属性 'version'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43024699/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
AttributeError: module 'numpy' has no attribute 'version'
提问by taylor
I am working on learning how to use pandas in ipython notebook:
我正在学习如何在 ipython notebook 中使用 pandas:
import pandas as pd
But I get the following error:
但我收到以下错误:
AttributeError Traceback (most recent call last)
<ipython-input-17-c7ecb2b0a99d> in <module>()
----> 1 from pandas import *
D:\Anaconda\lib\site-packages\pandas\__init__.py in <module>()
20
21 # numpy compat
---> 22 from pandas.compat.numpy import *
23
24 try:
D:\Anaconda\lib\site-packages\pandas\compat\numpy\__init__.py in <module>()
8
9 # numpy versioning
---> 10 _np_version = np.version.short_version
11 _nlv = LooseVersion(_np_version)
12 _np_version_under1p8 = _nlv < '1.8'
AttributeError: module 'numpy' has no attribute 'version'
I have no idea about how to fix it, what is the problem?My python's version is 3.6
我不知道如何修复它,有什么问题?我的python版本是3.6
回答by Marcin
Numpy has dependencies and Anaconda has a history of getting them wrong leading to numpy failing to initialize properly. The AttributeError
is most likely caused by numpy initialization failure. This error usually happens when updating numpy or other dependencies that change numpy versions via conda (that's why you can get numpy failing after updating Pandas...)
Numpy 有依赖关系,而 Anaconda 有将它们弄错的历史,导致 numpy 无法正确初始化。这AttributeError
很可能是由 numpy 初始化失败引起的。此错误通常发生在通过 conda 更新 numpy 或其他更改 numpy 版本的依赖项时(这就是为什么在更新 Pandas 后您可能会遇到 numpy 失败的原因...)
Example of such failure: https://github.com/ipython/ipyparallel/issues/326
此类失败的示例:https: //github.com/ipython/ipyparallel/issues/326
The solution that alwaysworks for me is updating to a known working version of numpy. Currently, for me on Windows 10 x64, it is 1.15.1.
始终适用于我的解决方案是更新到已知的 numpy 工作版本。目前,对于我在 Windows 10 x64 上,它是 1.15.1。
Please note it is a problem with Anaconda dependenciesrather than numpy itself. Can't provide more specific guidance without details like OS, package versions, etc.
请注意,这是Anaconda 依赖项而不是 numpy 本身的问题。如果没有操作系统、软件包版本等详细信息,则无法提供更具体的指导。