user3477071
user3477071

Reputation: 304

Cannot import numpy in python3

I am using python3 in Ubuntu Xenial. I also have version 1.11.0 of python3-numpy package installed

I get errors when attempting to import numpy from python3.

$ python3.6
Python 3.6.5 (default, Mar 29 2018, 03:28:50) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 180, in <module>
    from . import add_newdocs
  File "/usr/lib/python3/dist-packages/numpy/add_newdocs.py", line 13, in <module>
    from numpy.lib import add_newdoc
  File "/usr/lib/python3/dist-packages/numpy/lib/__init__.py", line 8, in <module>
    from .type_check import *
  File "/usr/lib/python3/dist-packages/numpy/lib/type_check.py", line 11, in <module>
    import numpy.core.numeric as _nx
  File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 14, in <module>
    from . import multiarray
ImportError: cannot import name 'multiarray'
>>> 

Upvotes: 0

Views: 7984

Answers (3)

Ananth
Ananth

Reputation: 2725

I simply uninstalled Numpy using:

pip3 uninstall numpy

Then re-installed it:

pip3 install numpy

And somehow this worked.

Upvotes: 2

Rishabh Bhatnagar
Rishabh Bhatnagar

Reputation: 640

What you can do is, Create an environment and then install numpy.

Steps :

virtualenv *your_environment_name*

source *your_environment_name/bin/activate*

sudo pip3 install numpy

Upvotes: 0

Elodin
Elodin

Reputation: 648

If you don't mind about what version you are using, you could try pip install numpy==1.7.2 or another older version. This problem has happened to a few people when trying to install the latest versions of numpy.

If you would really like to use it, I would suggest reinstalling numpy. However, using pip uninstall numpy has been known to not work, so manually going into the Python directory, and Lib, and manually deleting the numpy packages would be your best bet.

If this still doesn't work, you may have to completely delete Python and reinstall it all over again.

The following websites may help you: Numpy build fails with cannot import multiarray, Python ImportError "cannot import name 'multiarray'

Upvotes: 0

Related Questions