简体   繁体   中英

PermissionError: pip upgrade from 8.1.1 to 8.1.2

I am trying to upgrading pip from 8.1.1 to 8.1.2 . But it showing following 'PermissionError: [WinError 5] Access is denied : How to upgrade pip?

C:\>python -m pip install --upgrade pip
Collecting pip
  Using cached pip-8.1.2-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 8.1.1
    Uninstalling pip-8.1.1:
Exception:
Traceback (most recent call last):
  File "C:\Program Files\Python35\lib\shutil.py", line 538, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files\\python35\\lib\\site-packages\\pip-8.1.1.dist-info\\description.rst' -> 'C:\\Users\\user\\AppD
ata\\Local\\Temp\\pip-nen4ldwg-uninstall\\program files\\python35\\lib\\site-packages\\pip-8.1.1.dist-info\\description.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python35\lib\site-packages\pip\basecommand.py", line 209, in main
    status = self.run(options, args)
  File "C:\Program Files\Python35\lib\site-packages\pip\commands\install.py", line 317, in run
    prefix=options.prefix_path,
  File "C:\Program Files\Python35\lib\site-packages\pip\req\req_set.py", line 726, in install
    requirement.uninstall(auto_confirm=True)
  File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", line 746, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:\Program Files\Python35\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "C:\Program Files\Python35\lib\site-packages\pip\utils\__init__.py", line 267, in renames
    shutil.move(old, new)
  File "C:\Program Files\Python35\lib\shutil.py", line 553, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'c:\\program files\\python35\\lib\\site-packages\\pip-8.1.1.dist-info\\description.rst'
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

This problem occurs even with administrator privileges.

open your cmd with admin priviliges. for that right click in icon and select open with administrator.

Upgrade PIP on your default python environment required sudo , ie in Windows term, you must your start command prompt as administrator mode. In fact, this is not recommended.

You don't need to use sudo /'Windows adminsitrators" if you setup virtualenv. It is python best practice to setup Python virtualenv , So you can separate the pip package required for individual project. For windows, it is similar setup .

Nevertheless, if you have decent PC with enough RAM, just install Virtualbox and deploy ubuntu. This way, your don't need to deal with windows python package installation/upgrade that overlook by developer (although all python package suppose to work out of the box) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM