无法正确安装python-pip模块

时间:2011-10-01 20:57:42

标签: python module installation 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 个答案:

答案 0 :(得分:5)

安装Python 2.7后,您是否安装了easy2install和PIP的Python 2.7版本?现有安装配置为默认使用Python 2.6,这可能会导致您的问题。

答案 1 :(得分:5)

您可能正在使用pip链接到python2.6而不是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