我正在尝试pip
按sudo
如下方式升级:
kurt@kurt-ThinkPad:~$ sudo pip install --upgrade pip
[sudo] password for kurt:
The directory '/home/kurt/.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/kurt/.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 up-to-date: pip in /usr/local/lib/python3.5/dist-packages
尽管消息以“要求已经是最新的”结尾,但如果我执行命令,pip
我会收到一条警告,提示我没有使用最新版本:
kurt@kurt-ThinkPad:~$ pip show dateutil
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
我该如何pip
正确升级?
答案1
您可以使用sudo
的-H
标志。错误消息中显示:
如果使用 sudo 执行 pip,您可能需要 sudo 的 -H 标志。
因此,正确的方法是:
sudo -H pip install --upgrade pip
-H
顺便说一下,标志将$HOME
变量设置为用户主页。