简体   繁体   English

Python - PIP 安装故障排除 - 权限错误:[WinError 5] 访问被拒绝

[英]Python - PIP install trouble shooting - PermissionError: [WinError 5] Access is denied

I get the following error when using PIP to either install new packages or even upgrade pip itself to the latest version.使用 PIP 安装新软件包或什至将 pip 本身升级到最新版本时出现以下错误。 I am running pip on a windows 8.1 machine with Python 3.4.我在 windows 8.1 机器上运行 pip Python 3.4。

The message is telling me I don't have Administrative Permission on the files (my account is an Administrator Account).该消息告诉我我没有文件的管理权限(我的帐户是管理员帐户)。

I would appreciate any thoughts on how to resolve this, as it is getting in the way of installing packages and progressing with Python.对于如何解决此问题的任何想法,我将不胜感激,因为它妨碍了安装软件包和 Python 的进展。

Error message:错误信息:

Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Removing file or directory c:\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst
      Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 523, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst' -> 'C:\\Users\\User\\AppData\\Local\\Temp\\pip-uze_sc4k-uninstall\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\basecommand.py", line 232, in main
    status = self.run(options, args)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\commands\install.py", line 347, in run
    root=options.root_path,
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_set.py", line 543, in install
    requirement.uninstall(auto_confirm=True)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_install.py", line 667, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\utils\__init__.py", line 316, in renames
    shutil.move(old, new)
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 536, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

E: Since this answer seems to have gained some popularity, I will add: doing things globally is most of the time not a great idea. E:由于这个答案似乎已经获得了一些人气,我要补充一点:在大多数情况下,在全球范围内做事并不是一个好主意。 Almost always the correct answer is: use a project environment where you're not installing things globally, eg with virtualenv .几乎总是正确的答案是:使用您没有全局安装东西的项目环境,例如使用virtualenv


For those that may run into the same issue:对于那些可能遇到相同问题的人:

Run the command prompt as administrator.以管理员身份运行命令提示符。 Having administrator permissions in the account is not always enough.在帐户中拥有管理员权限并不总是足够的。 In Windows, things can be run as administrator by right-clicking the executable and selecting "Run as Administrator".在 Windows 中,可以通过右键单击可执行文件并选择“以管理员身份运行”来以管理员身份运行。 So, type "cmd" to the Start menu, right click cmd.exe, and run it as administrator.因此,在开始菜单中键入“cmd”,右键单击 cmd.exe,然后以管理员身份运行它。

I know my answer would be weird but that's what I have experienced just now.我知道我的回答会很奇怪,但这就是我刚才所经历的。

I got the similar error when installing tensorflow package and I tried the same by opening powershell in windows as administrator but in vain.我在安装 tensorflow 包时遇到了类似的错误,我通过以管理员身份在 windows 中打开 powershell 尝试了同样的错误,但徒劳无功。

Later I found out that I was already using numpy in one of the python scripts in an active python session.后来我发现我已经在一个活动的 python 会话中的一个 python 脚本中使用了 numpy。 So I closed the Spyder IDE and tried to install the tensorflow package by running powershell as administrator and it worked.所以我关闭了 Spyder IDE 并尝试通过以管理员身份运行 powershell 来安装 tensorflow 包,它工作正常。

Hope this will help somebody else like me who will open this older but useful post in upcoming days希望这会帮助像我这样的其他人,他们将在未来几天打开这个较旧但有用的帖子

Even you run from Administrator, it may not solve the issue if the pip is installed inside another userspace.即使您从管理员运行,如果 pip 安装在另一个用户空间中,它也可能无法解决问题。 This is because Administrator doesn't own another's userspace directory, thus he can't see (go inside) the inside of the directory that is owned by somebody.这是因为管理员不拥有他人的用户空间目录,因此他无法看到(进入)某人拥有的目录内部。 Below is an exact solution.下面是一个确切的解决方案。

python -m pip install -U pip --user //In Windows 

Note: You should provide --user option注意:您应该提供 --user 选项

pip install -U pip --user //Linux, and MacOS

For those who run into this issue and running the command prompt as administrator does not work this worked for me:对于那些遇到此问题并以管理员身份运行命令提示符不起作用的人,这对我有用:

Since I had already tried a first time without running the cmd prompt as admin, in my c:\Users\"USER"\AppData\Local\Temp folder I found it was trying to run files from the same pip-u2e7e0ad-uninstall folder.由于我已经尝试过第一次没有以管理员身份运行 cmd 提示符,因此在我的c:\Users\"USER"\AppData\Local\Temp文件夹中,我发现它正在尝试从同一个pip-u2e7e0ad-uninstall文件夹运行文件. Deleting this folder from the Temp folder and retrying the installation fixed the issue for me.Temp文件夹中删除此文件夹并重试安装解决了我的问题。

Do not use the command prompt in the IDE.不要在 IDE 中使用命令提示符。 Run the command prompt from windows as an administrator.以管理员身份从 Windows 运行命令提示符。 I'm sure this will solve the problem.我相信这会解决问题。 If not, uninstall pip and reinstall the latest one directly.如果没有,请卸载 pip 并直接重新安装最新的。

As of upgrading from pip 7.xx to 8.xx on Python 3.4 (for *.whl support).在 Python 3.4 上从 pip 7.xx 升级到 8.xx(用于 *.whl 支持)。

Wrong command: pip install --upgrade pip (can't move pip.exe to temporary folder, permisson denied)错误命令: pip install --upgrade pip (不能将 pip.exe 移动到临时文件夹,权限被拒绝)

OK variant: py -3.4 -m pip install --upgrade pip (do not execute pip.exe) OK变体: py -3.4 -m pip install --upgrade pip (不执行pip.exe)

I have had the same problem with anaconda on windows.我在 Windows 上对 anaconda 也有同样的问题。 It seems that there is an issu with mcAfee antivirus.似乎 mcAfee 防病毒软件存在问题。 If you deactivate it while running the updates or the installs, it allows you to properly run the installation.如果您在运行更新或安装时停用它,它可以让您正确运行安装。

After seeing看过之后

You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

I ran我跑了

pip install -U pip

and hit this error并遇到此错误

PermissionError: [WinError 5]

I tried again and got我又试了一次,得到了

pip install -U pip
ERROR: To modify pip, please run the following command:
c:\python36-32\python.exe -m pip install -U pip

After running that exact command, it worked.运行该确切命令后,它起作用了。

For those promoting the use of virtual environments as a solution to this error, pip and virtualenv must be updated in your main install.对于那些提倡使用虚拟环境作为解决此错误的方法的人,必须在主安装中更新 pip 和 virtualenv。 Simply put, a virtual environment offers no solution to this problem.简而言之,虚拟环境无法解决这个问题。

TL;DR : python -m pip install -U pip , then try again. TL;DR : python -m pip install -U pip ,然后再试一次。


I was already using a venv (virtualenv) in PyCharm.我已经在 PyCharm 中使用了venv (virtualenv)。

Creating it I clicked inherit global site packages checkbox, to allow packages installed via an installer to work.创建它我单击了inherit global site packages复选框,以允许通过安装程序安装的包工作。 Now inside my venv there was no pip installed, so it would use the inherited global pip .现在在我的venv里面没有安装pip ,所以它会使用继承的全局pip

Here is how the error went:以下是错误的发生方式:

(venv) D:\path\to\my\project> pip install certifi  # or any other package

Would fail with会失败

PermissionError: [WinError 5] Access denied: 'c:\\program files\\python36\\Lib\\site-packages\\certifi'

Notice how that is the path of the system python, not the venv one.注意那是系统 python 的路径,而不是venv路径。 However we want it to execute in the right environment.但是,我们希望它在正确的环境中执行。

Here some more digging:这里还有一些挖掘:

(venv) D:\path\to\my\project> which pip
/c/Program Files/Python36/Scripts/pip

(venv) D:\path\to\my\project> which python
/d/path/to/my/project/venv/Scripts/python

So python is using the correct path, but pip is not?所以python使用的是正确的路径,但pip不是? Let's install pip here in the correct one as well:让我们在这里也安装正确的 pip:

(venv) D:\path\to\my\project> python -m pip install -U pip
... does stuff ...
Successfully installed pip

Now that's better.现在好多了。 Running the original failing command again now works, as it is using the correct pip.现在再次运行原来的失败命令可以正常工作,因为它使用了正确的 pip。

(venv) D:\path\to\my\project> pip install certifi  # or any other package
... install noise ...
Successfully installed certifi-2019.9.11 chardet-3.0.4 idna-2.8 requests-2.22.0 urllib3-1.25.7

I get the following error when using PIP to either install new packages or even upgrade pip itself to the latest version.使用PIP安装新软件包或什至将pip本身升级到最新版本时,出现以下错误。 I am running pip on a windows 8.1 machine with Python 3.4.我在使用Python 3.4的Windows 8.1机器上运行pip。

The message is telling me I don't have Administrative Permission on the files (my account is an Administrator Account).该消息告诉我我对文件没有管理权限(我的帐户是管理员帐户)。

I would appreciate any thoughts on how to resolve this, as it is getting in the way of installing packages and progressing with Python.我将不胜感激如何解决此问题,因为它正在阻碍软件包的安装和Python的发展。

Error message:错误信息:

Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Removing file or directory c:\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst
      Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 523, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst' -> 'C:\\Users\\User\\AppData\\Local\\Temp\\pip-uze_sc4k-uninstall\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\basecommand.py", line 232, in main
    status = self.run(options, args)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\commands\install.py", line 347, in run
    root=options.root_path,
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_set.py", line 543, in install
    requirement.uninstall(auto_confirm=True)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_install.py", line 667, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\utils\__init__.py", line 316, in renames
    shutil.move(old, new)
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 536, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

I get the following error when using PIP to either install new packages or even upgrade pip itself to the latest version.使用PIP安装新软件包或什至将pip本身升级到最新版本时,出现以下错误。 I am running pip on a windows 8.1 machine with Python 3.4.我在使用Python 3.4的Windows 8.1机器上运行pip。

The message is telling me I don't have Administrative Permission on the files (my account is an Administrator Account).该消息告诉我我对文件没有管理权限(我的帐户是管理员帐户)。

I would appreciate any thoughts on how to resolve this, as it is getting in the way of installing packages and progressing with Python.我将不胜感激如何解决此问题,因为它正在阻碍软件包的安装和Python的发展。

Error message:错误信息:

Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Removing file or directory c:\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst
      Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 523, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst' -> 'C:\\Users\\User\\AppData\\Local\\Temp\\pip-uze_sc4k-uninstall\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\basecommand.py", line 232, in main
    status = self.run(options, args)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\commands\install.py", line 347, in run
    root=options.root_path,
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_set.py", line 543, in install
    requirement.uninstall(auto_confirm=True)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_install.py", line 667, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\utils\__init__.py", line 316, in renames
    shutil.move(old, new)
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 536, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

Still relevant in 2018: don't install packages as admin.在 2018 年仍然相关:不要以管理员身份安装软件包。

The by far more sensible solution is to use virtualenv to create a virtual environment directory ( virtualenv dirname ) and then activate that virtual environment with dirname\Script\Activate in Windows before running any pip commands.迄今为止更明智的解决方案是使用virtualenv创建一个虚拟环境目录 ( virtualenv dirname ),然后在运行任何 pip 命令之前在 Windows 中使用dirname\Script\Activate激活该虚拟环境。 Or use pipenv to manage the installs for you.或者使用pipenv为您管理安装。

That way, everything gets written to dirs that you have full write permission for, without needing UAC, and without global installs for local directories.这样,所有内容都会写入您拥有完全写入权限的目录,无需 UAC,也无需为本地目录进行全局安装。

Note that if you are installing this through Anaconda, you will need to open Anaconda as an administrator and then launch the command prompt from there.请注意,如果您通过 Anaconda 安装它,您需要以管理员身份打开 Anaconda,然后从那里启动命令提示符。

Otherwise, you can also run "Anaconda prompt" directly as an administrator to uninstall and install packages.否则,您也可以直接以管理员身份运行“Anaconda prompt”来卸载和安装软件包。

I get the following error when using PIP to either install new packages or even upgrade pip itself to the latest version.使用PIP安装新软件包或什至将pip本身升级到最新版本时,出现以下错误。 I am running pip on a windows 8.1 machine with Python 3.4.我在使用Python 3.4的Windows 8.1机器上运行pip。

The message is telling me I don't have Administrative Permission on the files (my account is an Administrator Account).该消息告诉我我对文件没有管理权限(我的帐户是管理员帐户)。

I would appreciate any thoughts on how to resolve this, as it is getting in the way of installing packages and progressing with Python.我将不胜感激如何解决此问题,因为它正在阻碍软件包的安装和Python的发展。

Error message:错误信息:

Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Removing file or directory c:\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst
      Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 523, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst' -> 'C:\\Users\\User\\AppData\\Local\\Temp\\pip-uze_sc4k-uninstall\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\basecommand.py", line 232, in main
    status = self.run(options, args)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\commands\install.py", line 347, in run
    root=options.root_path,
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_set.py", line 543, in install
    requirement.uninstall(auto_confirm=True)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_install.py", line 667, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\utils\__init__.py", line 316, in renames
    shutil.move(old, new)
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 536, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

I get the following error when using PIP to either install new packages or even upgrade pip itself to the latest version.使用PIP安装新软件包或什至将pip本身升级到最新版本时,出现以下错误。 I am running pip on a windows 8.1 machine with Python 3.4.我在使用Python 3.4的Windows 8.1机器上运行pip。

The message is telling me I don't have Administrative Permission on the files (my account is an Administrator Account).该消息告诉我我对文件没有管理权限(我的帐户是管理员帐户)。

I would appreciate any thoughts on how to resolve this, as it is getting in the way of installing packages and progressing with Python.我将不胜感激如何解决此问题,因为它正在阻碍软件包的安装和Python的发展。

Error message:错误信息:

Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Removing file or directory c:\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst
      Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 523, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst' -> 'C:\\Users\\User\\AppData\\Local\\Temp\\pip-uze_sc4k-uninstall\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\basecommand.py", line 232, in main
    status = self.run(options, args)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\commands\install.py", line 347, in run
    root=options.root_path,
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_set.py", line 543, in install
    requirement.uninstall(auto_confirm=True)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_install.py", line 667, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\utils\__init__.py", line 316, in renames
    shutil.move(old, new)
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 536, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

I ran into this issue when I was using pycharm to create and run a virtual environment - I clicked the "inherit global site packages" checkbox - deleting and recreating the venv solved the issue for me.我在使用 pycharm 创建和运行虚拟环境时遇到了这个问题——我点击了“继承全局站点包”复选框——删除并重新创建 venv 为我解决了这个问题。 If you used another means for creating your venv, make sure it IS NOT INHERITING global packages!如果您使用另一种方法来创建您的 venv,请确保它没有继承全局包! 在此处输入图像描述

I get the following error when using PIP to either install new packages or even upgrade pip itself to the latest version.使用PIP安装新软件包或什至将pip本身升级到最新版本时,出现以下错误。 I am running pip on a windows 8.1 machine with Python 3.4.我在使用Python 3.4的Windows 8.1机器上运行pip。

The message is telling me I don't have Administrative Permission on the files (my account is an Administrator Account).该消息告诉我我对文件没有管理权限(我的帐户是管理员帐户)。

I would appreciate any thoughts on how to resolve this, as it is getting in the way of installing packages and progressing with Python.我将不胜感激如何解决此问题,因为它正在阻碍软件包的安装和Python的发展。

Error message:错误信息:

Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Removing file or directory c:\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst
      Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 523, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst' -> 'C:\\Users\\User\\AppData\\Local\\Temp\\pip-uze_sc4k-uninstall\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\basecommand.py", line 232, in main
    status = self.run(options, args)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\commands\install.py", line 347, in run
    root=options.root_path,
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_set.py", line 543, in install
    requirement.uninstall(auto_confirm=True)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_install.py", line 667, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\utils\__init__.py", line 316, in renames
    shutil.move(old, new)
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 536, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

I have the same error.我有同样的错误。 Not sure why it happened.不知道为什么会这样。 But I managed to upgrade by running:但我设法通过运行升级:

pip install setuptools --upgrade --ignore-installed

After that, I used a PowerShell or Command Prompt - cmd in administrator mode to install the package:之后,我使用PowerShellCommand Prompt - 管理员模式下的 cmd 来安装软件包:

pip install the-package

# or
easy_install the-package

Also, what they have already suggested: Installing packages using pip and virtual environments , which is the best practice for new projects.此外,他们已经建议: 使用 pip 和虚拟环境安装包,这是新项目的最佳实践。

I get the following error when using PIP to either install new packages or even upgrade pip itself to the latest version.使用PIP安装新软件包或什至将pip本身升级到最新版本时,出现以下错误。 I am running pip on a windows 8.1 machine with Python 3.4.我在使用Python 3.4的Windows 8.1机器上运行pip。

The message is telling me I don't have Administrative Permission on the files (my account is an Administrator Account).该消息告诉我我对文件没有管理权限(我的帐户是管理员帐户)。

I would appreciate any thoughts on how to resolve this, as it is getting in the way of installing packages and progressing with Python.我将不胜感激如何解决此问题,因为它正在阻碍软件包的安装和Python的发展。

Error message:错误信息:

Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Removing file or directory c:\program files (x86)\python\python34\lib\site-packages\pip-6.0.8.dist-info\description.rst
      Cleaning up...
Exception:
Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 523, in move
    os.rename(src, real_dst)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst' -> 'C:\\Users\\User\\AppData\\Local\\Temp\\pip-uze_sc4k-uninstall\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\basecommand.py", line 232, in main
    status = self.run(options, args)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\commands\install.py", line 347, in run
    root=options.root_path,
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_set.py", line 543, in install
    requirement.uninstall(auto_confirm=True)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_install.py", line 667, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\req\req_uninstall.py", line 126, in remove
    renames(path, new_path)
  File "C:\Program Files (x86)\Python\Python34\lib\site-packages\pip\utils\__init__.py", line 316, in renames
    shutil.move(old, new)
  File "C:\Program Files (x86)\Python\Python34\lib\shutil.py", line 536, in move
    os.unlink(src)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python\\python34\\lib\\site-packages\\pip-6.0.8.dist-info\\description.rst'

I had the same problem and I used these steps to solve it.我有同样的问题,我使用这些步骤来解决它。

  1. I added the path into "system environment variables".我将路径添加到“系统环境变量”中。
  2. I changed the "Registry editor".我更改了“注册表编辑器”。 In order to do that, type "regeidt" in run, then open the "Registry editor".为此,请在运行中键入“regeidt”,然后打开“注册表编辑器”。 Go to "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem", choose "LongPathsEnabled" and change the "Valuedata" to "1" press the "Ok", and restart the computer.转到“HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem”,选择“LongPathsEnabled”并将“Valuedata”更改为“1”,按“Ok”,然后重新启动计算机。
  3. Run "Command Prompt" as an "administrator" and type "pip install scikit-learn".以“管理员”身份运行“命令提示符”并输入“pip install scikit-learn”。

Was facing this issue on windows when upgrading pip inside a virtual environment so in a loaded venv try在虚拟环境中升级 pip 时在 Windows 上遇到此问题,因此在加载的 venv 中尝试

python -m pip install --upgrade pip

instead of using normal command like而不是使用普通命令

pip install --upgrade pip #X pip install --upgrade pip #X

Can't use --user here, as we are in venv不能在这里使用 --user ,因为我们在 venv

In my case, when I went into the properties of AppData folder, there were two checked check-boxes - one for 'Read-Only' and one for 'hidden'.就我而言,当我进入 AppData 文件夹的属性时,有两个选中的复选框 - 一个用于“只读”,一个用于“隐藏”。 I unchecked the 'hidden' option.我取消选中“隐藏”选项。 It took 5 minutes to process.处理需要5分钟。 After that, I was able to install the packages successfully from cmd in administrator mode.之后,我能够以管理员模式从 cmd 成功安装软件包。

下面为我​​工作

$ python -m pip install --user --upgrade pip

Working inside a venv in Windows 10 that I received the error when using the PowerShell terminal inside VS Code.在 Windows 10 的 venv 中工作,在 VS Code 中使用 PowerShell 终端时收到错误消息。 When using the command prompt terminal pip was upgraded successfully.使用命令提示符终端 pip 升级成功。

I had a similar problem after upgrading my python installation (with scoop).升级我的 python 安装(使用 scoop)后,我遇到了类似的问题。 The problem in my case was that the pip configuration was messed up:我的问题是pip 配置被搞砸了:

pip config list                                                                                                   
global.target='C:/Program Files/Python310/Lib/site-packages'
global.trusted-host='pypi.python.org\npypi.org\nfiles.pythonhosted.org'

so I had to manually edit the global.target in the pip configuration.所以我不得不手动编辑global.target配置中的 global.target。

pip config set global.target C:\Users\[User]\scoop\apps\python\current\Lib\site-packages

Just reinstall Python in another folder, eg c:\python .只需在另一个文件夹中重新安装 Python,例如c:\python After that you won't be bothered by pip wanted administrator privileges.之后,您将不会被pip想要的管理员权限所困扰。

Windows 10 Pro x64 user. Windows 10 专业版 x64 用户。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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