Python 尝试在 Windows 上 pip 安装包时访问被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51115744/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 19:43:48  来源:igfitidea点击:

Access is denied when trying to pip install a package on Windows

python

提问by Shwetali Rane

How to set path for python 3.7.0 ? i tried the every possible way but it still shows the error!!!

如何为 python 3.7.0 设置路径?我尝试了所有可能的方法,但它仍然显示错误!!!

Could not install packages due to an EnvironmentError: [WinError 5]

Access is denied: 'c:\program files (x86)\python37-32\lib\site-packages\pip-10.0.1.dist-info\entry_points.txt'

Consider using the --useroption or check the permissions

由于环境错误,无法安装软件包:[WinError 5]

访问被拒绝:'c:\program files (x86)\python37-32\lib\site-packages\pip-10.0.1.dist-info\entry_points.txt'

考虑使用该--user选项或检查权限

回答by Surendiran S

Add --userto the command.

添加--user到命令中。

eg:

例如:

  pip install -r requirements.txt --user

回答by lionxlamb

Run your command Prompt on Admin-Mode in Windows,it will stop throwing errors for user-rights.

在 Windows 的管理员模式下运行您的命令提示,它将停止抛出用户权限错误。

Steps:

脚步:

  1. On Windows, type "Cmd" on searchbox to search for command prompt.

  2. When "Command Prompt" search result appears,right-click>Run as Administrator.

  1. 在 Windows 上,在搜索框中键入“Cmd”以搜索命令提示符。

  2. 出现“命令提示符”搜索结果时,右键单击>以管理员身份运行。

回答by isherwood

Append the --usermodifier to your command as suggested in the error.

--user按照错误中的建议将修饰符附加到您的命令中。

--usermakes pip install packages in your home directory instead, which doesn't require any special privileges.

--user而是在您的主目录中制作 pip install 软件包,这不需要任何特殊权限。

More: What is the purpose "pip install --user ..."?

更多:“pip install --user ...”的目的是什么?

回答by Van Anh Ki?u Thanh

You can add --user in the end of your command. This works well in my case!

您可以在命令末尾添加 --user 。这在我的情况下效果很好!

--user

My example:

我的例子:

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

回答by Alkesh Mahajan

Just try on Administrator cmd

试试管理员cmd

pip install --user numpy

回答by Sang9xpro

Run your command prompt on admin mode. type :

在管理员模式下运行命令提示符。类型 :

cd\

cd\

then type:

然后输入:

cd [Your python location path]

cd [Your python location path]

on mycomputer it's: cd C:\Users\hp\AppData\Local\Programs\Python\Python37-32then type:

在我的电脑上它是: cd C:\Users\hp\AppData\Local\Programs\Python\Python37-32然后输入:

python -m pip install --upgrade pip

You can follow this guide~ https://datatofish.com/upgrade-pip/

你可以按照这个指南~ https://datatofish.com/upgrade-pip/

回答by molecoder

I had the same problem.

我有同样的问题。

After installing Python for all the users, wanted to install Django.

为所有用户安装 Python 后,想安装 Django。

For that I've gone to the Command Prompt (without using Admin mode) and

为此,我进入了命令提示符(不使用管理员模式)和

pip.exe install django==2.2

This prompted the following message

这提示了以下消息

Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\program files\python37\lib\site-packages\pip-19.0.3.dist-info\entry_points.txt' Consider using the --useroption or check the permissions.

由于环境错误,无法安装包:[WinError 5] 访问被拒绝:'c:\program files\python37\lib\site-packages\pip-19.0.3.dist-info\entry_points.txt' 考虑使用该--user选项或检查权限。

The way I've used to solve it was to add --userin the end of the command, just like the prompt message suggests (?Consider using the --user?).

我用来解决它的方法是在命令的末尾添加--user,就像提示消息所暗示的一样(?考虑使用--user?)。

pip.exe install django==2.2 --user

Then everything worked fine.

然后一切正常。

回答by mr_yager

I wanted to throw an answer out here because I've been against a rock wall since upgrading to python 3.18. Pip install stopped working with a module error which was rectified with py -m pip install --user. butI would still get this permissions error. I uninstalled, reinstalled, and downgraded Python and Pip. I ran command prompt as administrator. None of it worked.

我想在这里给出一个答案,因为自从升级到 python 3.18 以来,我一直在碰壁。Pip install 因模块错误而停止工作,该错误已通过 py -m pip install --user 纠正。 我仍然会收到此权限错误。我卸载、重新安装并降级了 Python 和 Pip。我以管理员身份运行命令提示符。它都没有奏效。

The only thing that worked was to pip download and then pip install the package from my c:/ drive. Totally BS workaround, but if you'r as stuck as I was it works.

唯一有效的方法是 pip 下载,然后从我的 c:/ 驱动器 pip 安装包。完全是 BS 解决方法,但如果你和我一样卡住了,它就可以工作。