任何想法如何在Windows框上更新python PIP?

pip install --upgrade pip无法正常工作,因为Windows FS受到脑部损坏,并且不允许您删除打开的文件。

我尝试将环境设置为要更新的virtualenv,然后从其他pip运行,但是失败了:

(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上没有问题。

boatcoder asked 2019-11-18T23:37:50Z
6个解决方案
111 votes

easy_install -U pip

:-)

Jonny Buchanan answered 2019-11-18T23:38:14Z
62 votes

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

python -m pip install -U pip
Christian Long answered 2019-11-18T23:38:37Z
17 votes

[UPDATE 2015-11-15]此帖已过时且过时。 当前的最佳做法是根据pip使用以下方法:

python -m pip install -U pip setuptools

不必使用setuptools中的-k。 在pip安装程序页面上建议的更新pip的过程是使用-k

要安装或升级pip,请安全下载-k

您可以在msysgit的Git Bash之类的Bash shell中使用以下命令。

user@machine ~$ curl -L https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py | python

使用-k选项进行重定向。 最近,GitHub更改了原始内容的URL,因此旧的原始-k URL已被重定向,并且在pip网站上已更改了该URL。 如果成功,您应该看到以下内容:

$ 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,请从Curl下载Windows二进制文件。 您需要一直滚动到底部,并获得GünterKnauf当前的官方Win32二进制文件(当前为7.29)并将其解压缩。 不必担心它是32位还是64位。 只要确保您获得了所有的铃声和口哨声(ssl,zlib等)即可。 现在,导航到下载curl的文件夹(可能是-k),打开提取的文件夹(可能是|),您应该找到curl.exe。 现在,在Windows Shell中,在提示符后键入此名称(它将使用您的用户名而不是myusername),将path\to\Curl\替换为下载的curl.exe文件的路径。

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

您需要-k选项,以允许curl在没有证书的情况下访问安全的GitHub pip网站。 另外,感谢Piotr Dobrogost向我介绍了Windows管道|,它节省了保存文件的步骤。

如果您已经拥有最新版本的pip,则会收到以下消息:

$ 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中也可以正常工作。

Mark Mikofski answered 2019-11-18T23:39:56Z
0 votes

尝试:
右键单击Anaconda提示符(以管理员身份运行)

>> conda update pip

(如果您使用的是Anaconda。PS:它对我有用)

OM Bharatiya answered 2019-11-18T23:40:29Z
-1 votes

pip install pip --upgrade

enter image description here为我工作

注意:确保在管理员模式下运行命令提示符

maheshmnj answered 2019-11-18T23:41:06Z
-1 votes

嘿,我只需使用CMD中的以下命令即可在Python 36上升级PIP

python -m pip install-升级pip

CMD : Upgrading PIP in Python 36

user2255224 answered 2019-11-18T23:41:38Z
translate from https://stackoverflow.com:/questions/4379970/any-idea-how-to-update-python-pip-on-a-windows-box