无法正确安装python-pip模块

2 python installation module 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
Run Code Online (Sandbox Code Playgroud)

这也是我的Python目录现在的样子http://pastie.org/2623543

Pra*_*ota 5

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

  • 好的我从源代码重新编译了Python 2.7.2,安装了`python-setuptools`,做了`sudo easy_install pip`然后`sudo pip install requests`工作正常. (3认同)

Hug*_*res 5

您可能正在使用pip链接到python2.6而不是2.7.如果你已经pip使用python2.7正确安装,你可以这样做:

pip-2.7 install requests
Run Code Online (Sandbox Code Playgroud)

如果没有,请尝试以这种方式安装:

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
Run Code Online (Sandbox Code Playgroud)