Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'numpy' has no attribute 'version'

I am working on learning how to use pandas in ipython notebook:

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

like image 462
taylor Avatar asked Mar 26 '17 03:03

taylor


1 Answers

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...)

Example of such failure: https://github.com/ipython/ipyparallel/issues/326

The solution that always works for me is updating to a known working version of numpy. Currently, for me on Windows 10 x64, it is 1.15.1.

Please note it is a problem with Anaconda dependencies rather than numpy itself. Can't provide more specific guidance without details like OS, package versions, etc.

like image 154
Marcin Avatar answered Oct 19 '22 23:10

Marcin