【发布时间】:2016-09-08 23:18:27
【问题描述】:
我有一些运行良好的代码,在一天中,我破坏了一些东西,现在我无法安装任何 python 模块。具体来说,我需要 numpy、matplotlib 和枕头。我无法安装其中任何一个。
但奇怪的是,它们似乎都安装得很好:
$ sudo pip install numpy
Collecting numpy
Downloading numpy-1.11.0-cp27-cp27mu-manylinux1_x86_64.whl (15.3MB)
100% |████████████████████████████████| 15.3MB 94kB/s
Installing collected packages: numpy
Successfully installed numpy-1.11.0
或者当我尝试时:
$ sudo apt-get install python-numpy
Reading package lists... Done
Building dependency tree
Reading state information... Done
Suggested packages:
python-nose python-numpy-dbg python-numpy-doc
The following NEW packages will be installed:
python-numpy
0 upgraded, 1 newly installed, 0 to remove and 20 not upgraded.
Need to get 0 B/1,763 kB of archives.
After this operation, 9,598 kB of additional disk space will be used.
Selecting previously unselected package python-numpy.
(Reading database ... 221259 files and directories currently installed.)
Preparing to unpack .../python-numpy_1%3a1.11.0-1ubuntu1_amd64.deb ...
Unpacking python-numpy (1:1.11.0-1ubuntu1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up python-numpy (1:1.11.0-1ubuntu1) ...
我使用的是 python 2.7,我使用的是 Ubuntu 16.04。
$ python
Python 2.7.5 (default, May 12 2016, 13:11:58)
[GCC 5.3.1 20160413] on linux2
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
>>>
它对我尝试安装的任何模块都执行此操作。任何帮助将不胜感激。
【问题讨论】:
-
which python和sudo pip -V的输出是什么? -
来自 /usr/local/lib/python2.7/dist-packages (python 2.7) 的 pip 8.1.2
-
会不会是您安装了多个 Python 并且只在其中一个上安装了 numpy?
-
这就是我的想法,但是,我不确定如何验证这一点。我试图卸载 python,但我最终删除了一些
ubuntu-desktop依赖项。 -
尝试使用
python -m pip install numpy进行安装,以确保您的pip和python版本指向同一个位置。
标签: python-2.7 numpy matplotlib pip python-module