Impulse of import Numpy AttributeError: object 'module' does not have attribute 'core'

import numpy as np File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/__init__.py", line 180, in <module> from . import add_newdocs File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module> from numpy.lib import add_newdoc File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module> from .type_check import * File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module> import numpy.core.numeric as _nx File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 57, in <module> from numpy.testing import Tester File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 14, in <module> from .utils import * File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/testing/utils.py", line 15, in <module> from tempfile import mkdtemp File "/usr/lib/python2.7/tempfile.py", line 35, in <module> from random import Random as _Random File "/home/anirrudh/OMSCS/Courses/ML4T/ml4t/mc3_p2/random.py", line 5, in <module> import matplotlib.pyplot as plt File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in <module> from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/matplotlib/cbook.py", line 33, in <module> import numpy.ma as ma File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/ma/__init__.py", line 44, in <module> from . import core File "/home/anirrudh/.virtualenvs/ml4t2/local/lib/python2.7/site-packages/numpy/ma/core.py", line 30, in <module> import numpy.core.umath as umath AttributeError: 'module' object has no attribute 'core' 

I am working on Ubuntu 14.04. I tried reinstalling numpy, created a new virtualenv, but that doesn't help. I get the same error outside of virtualenv. He suddenly stopped working. It was good until a little back.

+7
source share
5 answers

(Answer sent on behalf of the OP).

Update: Allowed.

I created a python file for one of my projects called random.py, and when numpy was imported, it would call that file instead of its own library file, which led to an error. I had to delete / rename random.py that I created and fixed the problem.

+21
source

Try running it in Python 2 instead of Python 3 - you may have an older version of Spark

+2
source

This happened to me on Windows with Anaconda. I fixed this by removing the python3 path from the PATH environment variable.

+1
source

Another common problem (which I had) ... make sure you don't have env var PYTHONPATH pointing to a different version of the python site packages (this was because I updated my version of python and didn't change that ... it first loaded with PYTHONPATH).

0
source

This happened to me in a particular ipynb, as soon as I recorded a copy of a laptop with a different name, I was able to import numpy.

0
source

Source: https://habr.com/ru/post/1237083/


All Articles