我正尝试在虚拟环境中升级pip。我在ubuntu 14.04机器上使用了venvburrito wrapper。当我尝试更新它,我得到以下错误:无法在虚拟环境中升级PIP
(virtual_env) [email protected]:~$ pip install pip --upgrade
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 8.1.2
Not uninstalling pip at /home/ubuntu/.venvburrito/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg, outside environment /home/ubuntu/.virtualenvs/virtual_env
Successfully installed pip-8.1.2
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.
如果我使用sudo尝试,在虚拟环境中,我得到以下错误:
(virtual_env) [email protected]:~$ sudo pip install --upgrade pip
The directory '/home/ubuntu/.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/ubuntu/.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.
/home/ubuntu/.local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/home/ubuntu/.local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Requirement already up-to-date: pip in ./.local/lib/python2.7/site-packages
/home/ubuntu/.local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
当我做到这一点以外虚拟环境,它安装正确。
任何帮助将不胜感激。
感谢
如果你不完全知道你在做什么,请不要使用'sudo pip'! 'sudo'不保留环境变量,所以它会“爆发”venv,并且可以改变系统python安装干扰本地安装的软件包。特别是如果你使用venvs,你永远不需要用sudo运行pip。 – mata
谢谢@mata,将注意到 – Escachator
@SiddheshMatre不错的工作,但你需要解释它是如何工作的kido,该点不能自行安装。 – 2017-03-01 11:41:49