Windows上的pip安装访问被拒绝

问题:Windows上的pip安装访问被拒绝

我试图运行pip install mitmproxy在Windows,但我不断收到拒绝访问,甚至cmdPowerShell使用Run as Administrator选项。

WindowsError: [Error 5] Access is denied: 'c:\\users\\bruno\\appdata\\local\\temp\\easy_install-0fme6u\\cryptography-0.9.1\\.eggs\\cffi-1.1.2-py2.7-win-amd64.egg\\_cffi_backend.pyd'

我该如何工作?

I am trying to run pip install mitmproxy on Windows, but I keep getting access denied, even with cmd and PowerShell using the Run as Administrator option.

WindowsError: [Error 5] Access is denied: 'c:\\users\\bruno\\appdata\\local\\temp\\easy_install-0fme6u\\cryptography-0.9.1\\.eggs\\cffi-1.1.2-py2.7-win-amd64.egg\\_cffi_backend.pyd'

How can I make this work?


回答 0

如果是Windows,请在cmd中尝试使用python可执行文件运行pip install

例如

python -m pip install mitmproxy

这应该工作,至少对其他软件包安装来说对我有用。

In case of windows, in cmd try to run pip install using python executable

e.g.

python -m pip install mitmproxy

this should work, at least it worked for me for other package installation.


回答 1

通过以下方式更改Python安装文件夹的安全权限:

  1. 打开一个Python shell
  2. 转到任务管理器
  3. 查找python进程
  4. 右键单击并打开位置
  5. 该文件夹将在资源管理器中打开,进入目录
  6. 右键单击该文件夹,然后选择属性
  7. 点击安全标签,然后点击“编辑”
  8. 添加所有人,并授予他们读取和写入的权限。
  9. 保存更改

如果您cmd以管理员身份打开;那么您可以执行以下操作:

如果您的中设置了Python PATH,则:

python -m pip install mitmproxy

Change your Python installation folder’s security permissions by:

  1. Open a Python shell
  2. Go to task manager
  3. Find the python process
  4. Right-click and open location
  5. The folder will open in explorer, go up a directory
  6. Right-click the folder and select properties
  7. Click the security tab and hit ‘edit’
  8. Add everyone and give them permission to Read and Write.
  9. Save your changes

If you open cmd as admin; then you can do the following:

If Python is set in your PATH, then:

python -m pip install mitmproxy

回答 2

我个人发现,以管理员cmd身份打开然后运行 似乎可以解决我的问题。 python -m pip install mitproxy

注意:-我通过以下方式安装了pythonchocolatey

Personally, I found that by opening cmd as admin then run python -m pip install mitproxy seems to fix my problem.

Note:- I installed python through chocolatey


回答 3

以前的答案中未涉及的另一件事,尽管以admin身份运行,但通常会在Windows上引起问题,并且使我无法安装某些软件包,如果有另一个程序使用了某些文件,则会得到相同的权限被拒绝错误。 (要么pip install)尝试访问。这是Windows真正愚蠢的“功能”,它会多次弹出,例如在尝试移动某些文件时。

此外,我不知道如何找出哪个程序锁定了特定文件,因此最简单的方法是在开始任何操作之前,特别是在运行例如Spyder或任何其他基于Python的软件之前,重新引导并进行安装。您也可以尝试关闭所有程序,但是要知道哪个程序实际保存一个文件可能很棘手。例如,对于一个目录,在该目录中打开一个Explorer窗口就足够了。

One additional thing that has not been covered in previous answers and that often cause issues on Windows and stopped me from installing some package despite running as admin is that you get the same permission denied error if there is another program that use some of the files you (or pip install) try to access. This is a really stupid “feature” of Windows that pops up many times, e.g. when trying to move some files.

In addition I have no clue how to figure out which program locks a particular file, so the easiest ting to do is to reboot and do the installation before starting anything, in particular before running e.g. Spyder or any other Python-based software. You can also try to close all programs, but it can be tricky to know which one actually holds a file. For a directory for example, it is enough that you have an Explorer window open at that directory.


回答 4

使用“以管理员身份运行”打开cmd并执行命令pip install mitmproxy。它将安装它。

Open cmd with “Run as administrator” and execute the command pip install mitmproxy. It will install it.


回答 5

因为,我是通过anaconda Prompt安装的。在我的情况下,它甚至都无法使用python -m pip install然后,我添加了这个

python -m pip install <package_name> --user

这个对我有用。

喜欢: python -m pip install "numpy-1.15.4+mkl-cp36-cp36m-win_amd64.whl" --user

请注意,双引号不是必需的,您可以提供要安装的软件包名称。

另一个您应该尝试以“以管理员身份运行”身份运行命令提示符,然后尝试pip安装。它应该工作。

As, i am installing through anaconda Prompt .In my case, it didn’t even work with python -m pip install Then, i add this

python -m pip install <package_name> --user

It works for me.

Like: python -m pip install mitmproxy --user

Another you should try that run the Command Prompt as Run as Administrator and then try pip install. It should work either.


回答 6

尝试授予完全控制python文件夹的权限。

找到python根目录->右键单击->属性->安全->编辑->授予用户完全控制权限->是并等待过程完成。

这个对我有用。

Try to give permission to full control the python folder.

Find the python root directory–>right button click–>properties–>security–>edit–>give users Full Control–>yes and wait the process finished.

It works for me.


回答 7

尝试c:\\users\\bruno\\appdata\\local\\temp\\easy_install-0fme6u手动删除文件夹,然后重试pip命令。

Try to delete the folder c:\\users\\bruno\\appdata\\local\\temp\\easy_install-0fme6u manually and then retry the pip command.


回答 8

打开命令提示符,因为Administrator仅在不使用Python可执行文件的情况下为我工作。右键单击命令提示符快捷方式,然后选择“以管理员身份运行”。然后运行以下命令。

pip install Django

Opening command prompt As Administrator just worked for me without using Python executable. Right click on command prompt shortcut and choose “Run as Administrator”. Then run the following command.

pip install Django

回答 9

在我的情况下,原因是打开了一个Jupyter笔记本,该笔记本正在导入相关的库。根本原因似乎是Windows错误,原因是该文件处于打开状态/正在使用中(另请参见@Robert的回答以及有关重新启动的建议)。

所以要验证的另一件事是没有其他python进程在运行。

对我来说,关闭笔记本服务器可以解决此问题。

The cause in my case was having a jupyter notebook open, which was importing the relevant library; the root cause seems to be windows error due to the file being open / in use (see also @Robert’s answer, and the recommendation to reboot).

So another thing to verify is that no other python processes are running.

For me, shutting down the notebook server solved the issue.


回答 10

  1. 以管理员身份打开命令提示符。

  2. 要安装任何Python软件包,请使用包括以下命令--user

pip install --ignore-installed --upgrade --user <packagename>

  1. Open Command Prompt as Administrator.

  2. To Install any Python Package use this command including --user.

pip install --ignore-installed --upgrade --user <packagename>


回答 11

当其他所有方法均失败时,请尝试退出您的IDE。我有很多情况都是PyCharm造成的。退出PyCharm之后,我终于能够从命令行安装我的软件包。另外,您也可以通过PyCharm本身在设置->项目:xxx->项目解释器->中进行安装+

When all else fails, try quitting your IDE. I had many cases in which PyCharm was causing this. As soon as I quit PyCharm, I was able to finally install my packages from the command line. Alternatively, you can also install through PyCharm itself in Settings -> Project: xxx -> Project Interpreter -> +.


回答 12

以管理员身份运行cmd.exe,然后键入:

python -m pip install

Run cmd.exe as an administrator then type:

python -m pip install

回答 13

我遇到了类似的问题。但是错误报告是关于

[SSL: TLSV1_ALERT_ACCESS_DENIED] tlsv1 alert access denied (_ssl.c:777)

首先,我尝试了此https://python-forum.io/Thread-All-pip-install-attempts-are-met-with-SSL-error#pid_28035,但似乎无法解决我的问题,仍然重复同样的问题。

其次,如果您在商用计算机上工作,通常它可能存在一个Web内容过滤器(但是我可以直接通过浏览器访问 https://pypi.python.org)。并通过添加代理服务器来解决此问题。

对于Windows,请Internet properties通过IE或Chrome或其他方式打开,然后设置有效的代理地址和端口,这样就可以解决我的问题

或者只是添加该选项pip --proxy [proxy-address]:port install mitmproxy。但是在通过pypi安装时,您始终需要添加此选项。

以上两种解决方案是您需要的替代方案。

I met a similar problem.But the error report is about

[SSL: TLSV1_ALERT_ACCESS_DENIED] tlsv1 alert access denied (_ssl.c:777)

First I tried this https://python-forum.io/Thread-All-pip-install-attempts-are-met-with-SSL-error#pid_28035 ,but seems it couldn’t solve my problems,and still repeat the same issue.

And Second if you are working on a business computer,generally it may exist a web content filter(but I can access https://pypi.python.org through browser directly).And solve this issue by adding a proxy server.

For windows,open the Internet properties through IE or Chrome or whatsoever ,then set valid proxy address and port,and this way solve my problems

Or just adding the option pip --proxy [proxy-address]:port install mitmproxy.But you always need to add this option while installing by pypi

The above two solution is alternative for you demand.


回答 14

就我而言,它甚至无法与 python -m pip install

我所做的是,以管理员身份通过cmd:

PsExec.exe -i -s -d cmd.exe

为了产生SYSTEM cmd,然后 pip install mitmproxy

;)

In my case, it didn’t even work with python -m pip install

What I have done is, from a cmd as administrator:

PsExec.exe -i -s -d cmd.exe

In order to spawn a SYSTEM cmd, then pip install mitmproxy

;)


回答 15

只需关闭所有打开的python文件。并尝试以管理员身份运行。会的。

例如

pip install numpy

Just close all the python files opened. And try to run as administrator. It will work.

e.g.

pip install numpy