2017-03-01 138 views
-1

我正嘗試在虛擬環境中升級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 

當我做到這一點以外虛擬環境,它安裝正確。

任何幫助將不勝感激。

感謝

+1

如果你不完全知道你在做什麼,請不要使用'sudo pip'! 'sudo'不保留環境變量,所以它會「爆發」venv,並且可以改變系統python安裝干擾本地安裝的軟件包。特別是如果你使用venvs,你永遠不需要用sudo運行pip。 – mata

+0

謝謝@mata,將注意到 – Escachator

+0

@SiddheshMatre不錯的工作,但你需要解釋它是如何工作的kido,該點不能自行安裝。 – 2017-03-01 11:41:49

回答

1

有時這會有所幫助(我有類似的問題,PIP不升級,並且第一個命令工作對我來說):

python -m ensurepip 

python -m ensurepip --upgrade 
+0

聽起來很有趣@Drako,但我得到'沒有模塊命名ensurepip'... – Escachator

+1

我不知道,因爲它是什麼版本,但它肯定包含在3.6 – Drako

+0

版本3.6的什麼?謝謝 – Escachator

-1

在虛擬環境中升級pip被只是一個PyPI package像任何其他;你可以用它來升級自己,你會升級任何包以同樣的方式:

pip install --upgrade pip 

在Windows和更安全的方法是run pip though a python module是:

python -m pip install --upgrade pip 

OR

python -m pip install -U pip 

在windows似乎有一個二進制代碼試圖替換自己的問題,這種方法可以解決這個限制。

+2

我不確定你是否閱讀我的問題。這正是沒有用的。 – Escachator

+0

嘗試一下然後決定。你不能使用'pip install pip --upgrade'來升級pip,這是不可能的,你必須做python -m pip install --upgrade pip。 –

+0

@SiddheshMatre很好的工作,但你需要解釋所有的小鬼,該點不能自己安裝。 – 2017-03-01 11:34:36