无法正确安装python-pip模块
我想安装一个模块,但是 pip
并没有把它安装到我认为应该放的地方,也就是 /usr/local/lib/python2.7/site-packages/
。今天我刚安装了 Python 2.7.2。之前我用的是 2.6.5,并且在那个版本上成功安装过模块。所以我觉得我的 Python 路径可能有问题。
我该怎么做才能让所有模块都安装到正确的 python2.7 目录呢?
s3z@s3z-laptop:~$ pip install requests
Requirement already satisfied: requests in /usr/local/lib/python2.6/dist-packages/requests-0.6.1-py2.6.egg
Installing collected packages: requests
Successfully installed requests
s3z@s3z-laptop:~$ python
Python 2.7.2 (default, Oct 1 2011, 14:26:08)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
>>> ^Z
[3]+ Stopped python
另外,这是我现在的 Python 目录结构 http://pastie.org/2623543
2 个回答
5
你可能在用的是和python2.6关联的pip
,而不是2.7。如果你已经正确安装了和python2.7一起用的pip
,你可以这样做:
pip-2.7 install requests
如果没有,那就试试这个安装方法:
curl -O http://python-distribute.org/distribute_setup.py
[sudo] python2.7 distribute_setup.py
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
[sudo] python2.7 get-pip.py
5
在你安装了Python 2.7之后,是否也安装了easy_install和PIP的Python 2.7版本?因为现在的安装可能默认使用的是Python 2.6,这可能是导致你遇到问题的原因。