无法使用 python-pip 正确安装模块

发布于 2024-12-07 11:07:21 字数 958 浏览 1 评论 0原文

我想安装一个模块,但 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

I would like to install a module but pip is not installing it in the right directory which I assume should be /usr/local/lib/python2.7/site-packages/. After all, I just installed Python 2.7.2 today. Originally I had 2.6.5 and had installed modules successfully there. So I think something is wrong with my Python path.

How to have all my module installations go to the proper python2.7 directory?

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

Also here is what my Python directories look like now http://pastie.org/2623543

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆梦 2024-12-14 11:07:21

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

After you installed Python 2.7, did you install the Python 2.7 version of easy_install and PIP? The existing installations are configured to use Python 2.6 by default which may be causing your issue.

┼── 2024-12-14 11:07:21

您可能正在使用链接到 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

You are probably using pip linked to python2.6, instead of 2.7. If you have installed pip properly with python2.7, you can do:

pip-2.7 install requests

If not, try installing this way:

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文