Python没有通过Linux上的pip找到已安装的软件包

时间:2015-07-08 20:50:42

标签: python linux numpy install pip

我一直在尝试用pip安装一些新的python包,但由于某种原因,python在安装后没有找到它们。这开始于我清除我的整个python安装,并使用apt-get重新安装它。我安装了:

python
python2.7
python2.7-dev
python-setuptools

当我跑步时:

sudo pip list

我明白了:

decorator (3.4.0)
flann (1.8.4)
ipython (3.2.0)
itsdangerous (0.24)
MarkupSafe (0.23)
numpy (1.9.2)
pexpect (3.1)
pip (7.1.0)
setuptools (18.0.1)
simplegeneric (0.8.1)
Werkzeug (0.10.4)

所以numpy被列为已安装。另外,一个

locate numpy

返回

/usr/bin/dh_numpy
/usr/include/numpy
/usr/include/python2.7/numpy
/usr/lib/python2.7/dist-packages/numpy
/usr/lib/python2.7/dist-packages/IPython/external/decorators/_numpy_testing_noseclasses.py
/usr/lib/python2.7/dist-packages/IPython/external/decorators/_numpy_testing_noseclasses.pyc
/usr/lib/python2.7/dist-packages/IPython/external/decorators/_numpy_testing_utils.py
/usr/lib/python2.7/dist-packages/IPython/external/decorators/_numpy_testing_utils.pyc
/usr/local/lib/python2.7/dist-packages/numpy
/usr/local/lib/python2.7/dist-packages/numpy-1.9.2.egg-info
/usr/share/numpy
/usr/share/doc/python-numpy
/usr/share/man/man1/dh_numpy.1.gz
/var/lib/dpkg/info/python-numpy.list
/var/lib/dpkg/info/python-numpy.md5sums
/var/lib/dpkg/info/python-numpy.postinst
/var/lib/dpkg/info/python-numpy.preinst
/var/lib/dpkg/info/python-numpy.prerm

所以看起来安装没问题。但是如果我尝试从python导入它,我会收到导入错误。我尝试了很多东西,比如清除整个python安装,清除pip,easy_install并重新安装所有这些,使用PYTHONPATH和PYTHONHOME变量进行批量处理,等等。作为参考,回显变量PYTHONPATH返回空,PYTHONHOME返回:

/usr

此外,sys.path变量包含:

['',
 '/usr/local/bin',
 '/usr/lib/python2.7',
 '/usr/lib/python2.7/plat-x86_64-linux-gnu',
 '/usr/lib/python2.7/lib-tk',
 '/usr/lib/python2.7/lib-old',
 '/usr/lib/python2.7/lib-dynload',
 '/usr/local/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages',
 '/usr/lib/python2.7/dist-packages/IPython/extensions']

所以它在/usr/lib/python2.7目录和/usr/local/lib/python2.7中查找。鉴于这个问题:

Python packages not available after install with pip

我怀疑这与pip正在服务的python的安装有关。但我只在/ usr / bin中有python,而不在/ usr / local / bin中,所以我不知道为什么pip在本地安装。另外,正如sys.path变量所示,python也应该查看/usar/local/python2.7。其他包装如烧瓶,bitarray和redis也有这个问题。谢谢你的帮助!

修改

要添加的另一个重要信息:which -a python输出/usr/bin/python,因此正在使用的python位于/ usr / bin。

1 个答案:

答案 0 :(得分:1)

如果您之前有另一个python安装,我怀疑pip仍然与旧版本相关联。 键入$ pip -V如果不是2.7为/Library/Frameworks/Python.framework/Versions/2.7/bin/pip2.7创建一个符号链接到usr / bin / pip 我看到包安装在正确的位置,所以也许你也可以试试$ python -V PS: 这应该作为评论,但我没有足够的“声誉”来添加评论。