2010-12-07 84 views
46

pip install --upgrade pip不起作用,因为Windows FS被脑损坏,不会让你删除一个打开的文件。任何想法如何更新窗口框上的Python PIP?

我已经尽我的环境设置,我想更新,然后从不同的点子运行的virtualenv,但失败:

(jm) E:\python\jm>c:\Python26\Scripts\pip install --upgrade pip 
Downloading/unpacking pip 
    Running setup.py egg_info for package pip 
    warning: no previously-included files matching '*.txt' found under directory 'docs\_build' 
    no previously-included directories found matching 'docs\_build\_sources' 
Installing collected packages: pip 
    Found existing installation: pip 0.7.1 
    Uninstalling pip: 
     Successfully uninstalled pip 
    Running setup.py install for pip 
    warning: no previously-included files matching '*.txt' found under directory 'docs\_build' 
    no previously-included directories found matching 'docs\_build\_sources' 
    Installing pip-script.py script to c:\Python26\Scripts 
    Installing pip.exe script to c:\Python26\Scripts 
    Installing pip.exe.manifest script to c:\Python26\Scripts 
    Installing pip-2.6-script.py script to c:\Python26\Scripts 
    Installing pip-2.6.exe script to c:\Python26\Scripts 
    Installing pip-2.6.exe.manifest script to c:\Python26\Scripts 
Exception: 
Traceback (most recent call last): 
    File "c:\Python26\lib\site-packages\pip-0.7.1-py2.6.egg\pip\basecommand.py", line 120, in main 
    File "c:\Python26\lib\site-packages\pip-0.7.1-py2.6.egg\pip\commands\install.py", line 165, in run 
    File "c:\Python26\lib\site-packages\pip-0.7.1-py2.6.egg\pip\req.py", line 1251, in install 
    File "c:\Python26\lib\site-packages\pip-0.7.1-py2.6.egg\pip\req.py", line 466, in commit_uninstall 
    File "c:\Python26\lib\site-packages\pip-0.7.1-py2.6.egg\pip\req.py", line 1549, in commit 
    File "c:\Python26\lib\shutil.py", line 216, in rmtree 
    rmtree(fullname, ignore_errors, onerror) 
    File "c:\Python26\lib\shutil.py", line 216, in rmtree 
    rmtree(fullname, ignore_errors, onerror) 
    File "c:\Python26\lib\shutil.py", line 221, in rmtree 
    onerror(os.remove, fullname, sys.exc_info()) 
    File "c:\Python26\lib\shutil.py", line 219, in rmtree 
    os.remove(fullname) 
WindowsError: [Error 5] Access is denied: 'c:\\users\\mark\\appdata\\local\\temp\\pip-gvsove-uninstall\\python26\\scripts\\pip.exe' 

Storing complete log in C:\Users\mark\AppData\Roaming\pip\pip.log 

(jm) E:\python\jm>dir c:\Users\mark\AppData\Local\temp\pip-gvsove-uninstall\python26\scripts 
Volume in drive C has no label. 
Volume Serial Number is 74E4-FE9F 

Directory of c:\Users\mark\AppData\Local\temp\pip-gvsove-uninstall\python26\scripts 

12/07/2010 11:32 AM <DIR>   . 
12/07/2010 11:32 AM <DIR>   .. 
05/14/2010 05:54 PM    7,168 pip.exe 
       1 File(s)   7,168 bytes 
       2 Dir(s) 22,824,603,648 bytes free 

(jm) E:\python\jm>del c:\Users\mark\AppData\Local\temp\pip-gvsove-uninstall\python26\scripts\pip.exe 

我希望其他人想出一个办法在这附近。它在Linux上没有问题....

+0

我得到了错误,但升级确实起作用。 – yoyo 2015-07-08 05:25:48

+0

很高兴看到3.5年之后,这仍然是一个问题,在Windows上使用最新的Python 2.7.10和pip 7.1.2。下面的建议没有解决它。太棒了。 – jarmod 2015-11-05 14:45:52

+0

为我工作的解决方案是[here](http://stackoverflow.com/a/17687817/2412846)。简而言之:您使用pip更新pip,但在运行时无法覆盖自身。将它复制到某处并从那里运行。 – davidhigh 2016-11-13 00:01:04

回答

92

easy_install -U pip

:-)

+2

太简单了。我不知道easy_install的确了解了virtualenvs。谢谢。 – boatcoder 2010-12-07 18:10:02

13

[更新2015年11月15日]这篇文章是过时和落伍。目前最好的做法是according to pip是使用以下命令:

python -m pip install -U pip setuptools 

这是没有必要使用easy_installsetuptools。从pip-installer页面推荐更新点的步骤是使用get-pip.py

要安装或升级PIP,安全地下载get-pip.py

您可以在Bash shellmsysgit's Git Bash中使用以下内容。

[email protected] ~$ curl -L https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | python 

使用-L选项可遵循重定向。最近GitHub更改了原始内容的网址,因此the old raw get-pip.py url已被redirected和点子网站the url was changed。如果成功的话,你应该看到以下内容:

$ curl -L https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | python 
    % Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
100 1309k 100 1309k 0  0 364k  0 0:00:03 0:00:03 --:--:-- 366k 
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-1.5.6-py2.py3-none-any.whl#md5=4d4fb4b69df6731c7aeaadd6300bc1f2 
Installing collected packages: pip 
    Found existing installation: pip 1.5.4 
    Uninstalling pip: 
     Successfully uninstalled pip 
Successfully installed pip 
Cleaning up... 

您可以修改此为Windows命令行,但首先,如果你不具备的libcurl,download a Windows binary from Curl。您需要一直滚动到底部并获取Günter Knauf's current official Win32 binary (currently 7.29)并将其解压缩。不要担心它是32位还是64位。只要确保你获得了所有的钟声和口哨声(ssl,zlib等)。现在导航到您下载卷曲的文件夹,可能是c:\Users\<you>\Downloads,打开解压缩的文件夹,可能是curl-7.29.0-rtmp-ssh2-ssl-sspi-zlib-idn-static-bin-w32,您应该找到curl.exe。好极了!现在在一个Windows外壳程序中,在提示符(它将使用您的用户名而不是myusername)之后键入此内容,将path\to\Curl\替换为下载的curl.exe文件的路径。

C:\Users\myusername> path\to\Curl\curl.exe -kL https://bootstrap.pypa.io/get-pip.py | python 

您需要-k选项允许卷曲而不证书访问安全GitHub的点子网站。另外,谢谢Piotr Dobrogost告诉我有关Windows管道的问题,|,这节省了保存文件的步骤。

如果您已经有最新版本的点子,你会得到以下信息:

$ curl https://bootstrap.pypa.io/get-pip.py | python 
    % Total % Received % Xferd Average Speed Time Time  Time Current 
           Dload Upload Total Spent Left Speed 
100 1309k 100 1309k 0  0 369k  0 0:00:03 0:00:03 --:--:-- 371k 
Requirement already up-to-date: pip in c:\python27\lib\site-packages 
Cleaning up... 

同样工作在virtualenvs就好了。

49

将pip作为脚本运行,使用python作为主要可执行文件。

python -m pip install -U pip