Importerror: Cannot Import Name 'Multiarray'

I installed Python3.6 as described here:

sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6

Then I installed numpy as follows:

sudo apt-get install python3-numpy

I guess I can import numpy from Python3.5 but not from 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'

How to fix this issue?

3 Answers

You probably have numpy installed only for your python3.5.

Instead of installing numpy through the Ubuntu repositories, you could try installing and using pip.
This is python's package manager. You can use it to install various python libraries like numpy.
Then use it to install numpy for your python3.6.

Installing pip:

Install pip with the following command:

apt install python-pip

Note: You may receive a Permission denied error. In this case just prefix your command with sudo e.g.:

sudo apt install python-pip

Then type in your terminal pip3.6 to check if you have it installed correctly. It should list you all its available parameters.

There are generally two options from here.

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.