ImportError:没有名为'numpy'的模块,但它就在那里! python 3.5

时间:2018-06-15 22:47:39

标签: python python-3.x numpy

我在这里缺少什么?有人可以在这里启发我吗?

步骤1.我正在尝试安装numpy。

  

aerin @ aerin-HP-Z230-Tower-Workstation:〜$ sudo pip install numpy

>     The directory '/home/aerin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been
> disabled. Please check the permissions and owner of that directory. If
> executing pip with sudo, you may want sudo's -H flag.
>     The directory '/home/aerin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled.
> check the permissions and owner of that directory. If executing pip
> with sudo, you may want sudo's -H flag.
>     Requirement already satisfied: numpy in /usr/local/lib/python3.5/dist-packages
>     You are using pip version 9.0.3, however version 10.0.1 is available.
>     You should consider upgrading via the 'pip install --upgrade pip' command.

第2步。好的。它说它在/usr/local/lib/python3.5/dist-packages。所以让我们使用numpy。

aerin@aerin-HP-Z230-Tower-Workstation:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01) 
[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>
ImportError: No module named 'numpy'

第3步。你在开玩笑吧?让我们看看它导入包的位置。

>import site; site.getsitepackages()

['/usr/local/lib/python3.5/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.5/dist-packages']

你说它在那里,但它给了我一个ImportError!如果有人暗示我在哪里看,我会很感激。谢谢!

2 个答案:

答案 0 :(得分:0)

不确定,但我认为你应该尝试:

sudo pip3 install numpy

如果这不起作用,请尝试为python2&amp; 3

重新安装numpy

答案 1 :(得分:0)

尝试升级pip并重新安装numpy

sudo pip install --upgrade pip
sudo pip install --reinstall numpy