【发布时间】:2020-05-18 12:18:21
【问题描述】:
我刚刚重新安装了 Ubuntu 16.04,然后做了一个 virtualenv 并尝试使用 Django 安装
sudo pip3 install django==3.0
但这会产生以下错误:
ERROR: Could not find a version that satisfies the requirement django==3.0
(from versions: 1.1.3, 1.1.4, 1.2, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5,
1.2.6, 1.2.7, 1.3, 1.3.1, 1.3.2, 1.3.3, ... 2.2.5, 2.2.6, 2.2.7, 2.2.8, 2.2.9)
ERROR: No matching distribution found for django==3.0
经过搜索,我觉得我的pip版本太低了,所以不知道Django的新版本。我尝试用
pip
sudo pip install --upgrade pip
但这给了
WARNING: The directory '/home/hugh/.cache/pip' or
its parent directory is not owned or is not writable by the current user.
The cache 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 up-to-date: pip in /usr/local/lib/python3.5/dist-packages (20.0.2)
我知道pip的最新版本是20.0.2。
为什么我不能安装 Django 3.0 版?
【问题讨论】:
-
旁白:请不要
sudo pip install。您正在将用户安装的包从 PyPI 转储到操作系统提供的 Python 包所在的位置。使用 virtualenvs 或--user,具体取决于您的具体用例。 -
@Chris 感谢您的提示!但我也在那里使用 virtualenv 和
sudo pip install。使用权也是错的吗? -
在 virtualenv 中你可能不需要
sudo。每次使用该命令时,请尝试考虑需要它的原因。如果您不需要它,请不要使用它。 -
我明白了。我只是认为可能有必要使用“sudo”。我不知道。谢谢!
-
只要确保创建没有
sudo的virtualenv,否则你可能会遇到权限问题:-)。