首页 > 解决方案 > ImportError:没有名为“numpy”的模块,但它就在那里!蟒蛇3.5

问题描述

我在这里想念什么?有人可以在这里启发我吗?

第 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!如果有人提示我在哪里看,我将不胜感激。谢谢!

标签: pythonpython-3.xnumpy

解决方案


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

sudo pip3 install numpy

如果这不起作用,请尝试为 python2&3 重新安装 numpy


推荐阅读