gpt4 book ai didi

Python3 pip3 无法安装requests

转载 作者:太空宇宙 更新时间:2023-11-04 12:28:21 29 4
gpt4 key购买 nike

在我的 Ubuntu 16.04 桌面上,我安装了 python2.7.12 和 python3.6.1。

seept@seept:~$ python --version
Python 2.7.12
seept@seept:~$ python3 --version
Python 3.6.1

我还安装了 pip 和 pip3。难道pip是针对python2的,pip3是针对python3的吗?

那么为什么 pip 的两个版本都给我显示这个:

seept@seept:~$ pip --version
pip 9.0.1 from /home/seept/.local/lib/python3.5/site-packages (python 3.5)
seept@seept:~$ pip3 --version
pip 9.0.1 from /home/seept/.local/lib/python3.5/site-packages (python 3.5)

为什么选择 Python 3.5?

seept@seept:~$ which python
/usr/bin/python

seept@seept:~$ which python3
/usr/local/bin/python3

seept@seept:~$ which pip
/home/seept/.local/bin/pip

seept@seept:~$ which pip3
/home/seept/.local/bin/pip3

所以我真正的问题是我需要 python3 项目的模块“请求”。

当我运行时:

seept@seept:~$ sudo pip3 install requests

这是输出:

The directory '/home/seept/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/seept/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
**Requirement already satisfied: requests in ./.local/lib/python3.5/site-packages**

顺便说一句,我总是收到这条消息:

You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

所以这个输出表明我正在使用 pip verison 8.1.1 但是当我运行 pip --version 它说我正在运行 9.0.1 版本。

对我来说,看起来我已经搞砸了,应该重新安装所有的东西吗?

最佳答案

您应该使用 virtualenv 运行您的项目。它可以保护您的项目目录并避免与其他版本发生冲突。

转到您的项目目录,然后使用以下命令安装第一个 virtualenv:

pip install virtualenv

在安装你的包之前运行这个来激活 virtualenv:

source venv/bin/activate

现在您的目录是安全的,您可以在此处安装您的包以保持安全且与其他目录不同。

希望你理解我的概念。

谢谢。

关于Python3 pip3 无法安装requests,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43975377/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com