最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】windows中python安装报错:ERROR Could not install packages due to an EnvironmentError WinError 5 拒绝访问

Python crifan 34318浏览 0评论

折腾:

【记录】Windows中新建VSCode的Python项目

期间,再去:

python -m pip install --upgrade pip

结果:

PS D:\dev\DevRoot\mitmdumpUrlSaver\pyinstaller> python -m pip install --upgrade pip
Collecting pip
  Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl (1.4MB)
     |████████████████████████████████| 1.4MB 504kB/s
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'c:\\program files\\python38\\lib\\site-packages\\pip-19.2.3.dist-info\\entry_points.txt'
Consider using the `--user` option or check the permissions.

WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

感觉,不去加–user,最好还是解决权限问题,否则后续pip安装其他库也会遇到此问题。

windows python ERROR Could not install packages due to an EnvironmentError WinError 5 拒绝访问

Python 更新pip报错:Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问_wang1114wang的博客-CSDN博客

python pip install 报错PermissionError: [WinError 5] 拒绝访问_simpleshao的博客-CSDN博客

给cmd加上权限,也麻烦,每次启动cmd都要加

Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。_qq_38410428的博客-CSDN博客

对于此处路径

‘c:\\program files\\python38\\lib\\site-packages\\pip-19.2.3.dist-info\\entry_points.txt’

其实就是python安装的根目录

c:\\program files\\python38

去加上权限,允许其他用户,非管理员,也可以访问

去修改权限,允许所有人的所有操作

还是不能完全操作

查看当前用户是:

再去允许试试,是否还有权限问题

PS D:\dev\DevRoot\mitmdumpUrlSaver\pyinstaller> python -m pip install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
Successfully installed pip-19.3.1

就没有权限问题了。

去看看目录的权限

PS D:\dev\DevRoot\mitmdumpUrlSaver\pyinstaller> ls -l 'C:\Program Files\Python38\'
    目录: C:\Program Files\Python38
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2019/12/30     18:16                DLLs
d-----       2019/12/30     18:16                Doc
d-----       2019/12/30     18:15                include
d-----       2019/12/30     18:16                Lib
d-----       2019/12/30     18:16                libs
d-----       2019/12/30     20:05                Scripts
d-----       2019/12/30     18:16                tcl
d-----       2019/12/30     18:16                Tools
-a----       2019/12/18     23:27          31322 LICENSE.txt
-a----       2019/12/18     23:27         879215 NEWS.txt
-a----       2019/12/18     23:27          99912 python.exe
-a----       2019/12/18     23:27         430080 python.pdb
-a----       2019/12/18     23:27          58952 python3.dll
-a----       2019/12/18     23:27        4191304 python38.dll
-a----       2019/12/18     23:27       11972608 python38.pdb
-a----       2019/12/18     23:27          98376 pythonw.exe
-a----       2019/12/18     23:27         430080 pythonw.pdb
-a----       2019/12/18     23:27          89752 vcruntime140.dll

PS D:\dev\DevRoot\mitmdumpUrlSaver\pyinstaller> ls -l 'C:\Program Files'

    目录: C:\Program Files

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       2019/11/18     17:32                3T Software Labs
d-----       2019/12/13     13:51                7-Zip
d-----        2019/7/16     11:39                Android
d-----        2019/6/18     10:27                Application Verifier
d-----       2019/12/18      9:40                Charles
d-----       2019/10/14     13:58                chromedriver
d-----        2019/5/24      0:12                Common Files
d-----        2019/6/19      9:42                Git
d-----         2019/7/1     11:34                Git LFS
d-----        2019/6/18     11:08                Intel
d-----       2019/10/11     12:06                internet explorer
d-----       2019/12/30     17:58                Java
d-----       2019/12/20     12:50                JetBrains
d-----         2019/7/8     11:02                Lenovo
d-----        2019/7/25     16:18                Manufacturer
d-----        2019/5/24      0:14                mcafee
d-----        2019/5/24      0:13                mcafee.com
d-----       2019/12/30     18:30                Microsoft VS Code
d-----        2019/6/18     14:58                MongoDB
d-----       2019/12/23      9:56                MongoDB Compass
d-----        2019/6/17     13:01                MySQL
d-----         2019/7/1     11:38                nodejs
d-----         2019/7/3      9:49                phantomjs-2.1.1-windows
d-----        2019/6/21     18:12                pstools
d-----       2019/12/30     18:16                Python38
d-----       2019/12/24      9:01                Redis
d-----        2019/6/17     11:32                Robo 3T 1.3.1
d-----       2019/10/17     16:14                SDData
d-----        2019/6/17     14:30                Tencent
d-----        2019/6/19     12:09                UNP
d-r---        2019/6/19     19:19                Windows Defender
d-----       2019/10/11     12:06                Windows Defender Advanced Threat Protection
d-----        2018/9/15     15:33                Windows Mail
d-----        2019/5/24     15:50                Windows Media Player
d-----        2018/9/16      0:05                Windows Multimedia Platform
d-----        2019/6/17     11:10                windows nt
d-----        2019/5/24     15:50                Windows Photo Viewer
d-----        2018/9/16      0:05                Windows Portable Devices
d-----        2018/9/15     15:33                Windows Security
d-----        2018/9/15     15:33                WindowsPowerShell
d-----       2019/12/14     15:12                WinRAR

PS D:\dev\DevRoot\mitmdumpUrlSaver\pyinstaller>

其中

d—–       2019/12/30     18:16                Python38

目前看不出是否有权限操作

总之是权限问题解决了。

【总结】

此处,windows中,python的pip去安装库,报错:

ERROR Could not install packages due to an EnvironmentError WinError 5 拒绝访问

普通的解决办法:

加上–user,比如:

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

表示,只给当前用户安装,同一电脑中其他用户就用不上了。

且每次安装库,都要加上–user

因为没权限访问对应目录。

此处目录是,python安装目录:

C:\Program Files\Python38

终极解决办法:

去给

C:\Program Files\Python38

目录,更改权限,允许你的用户,甚至其他用户,都能访问。

这样后续安装库就不用加–user了。

以后可以方便的pip去install库了。

具体步骤:

资源管理器 打开 目录 C:\Program Files\ -》 右键 C:\Program Files\Python38 -》 安全-> 组或用户名 选中  Users(DESKTOP-xxx\Users) (和TrustedInstaller) -》 编辑 -》 在弹框中,再去分别选中Users(DESKTOP-xxx\Users) (和TrustedInstaller),下面的Users的权限中 最顶部的 完全控制 点击 允许 则自动勾选其余选项 -》确定

即可 给 C:\Program Files\Python38 授权允许当前用户(和安装器)访问权限。

转载请注明:在路上 » 【已解决】windows中python安装报错:ERROR Could not install packages due to an EnvironmentError WinError 5 拒绝访问

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. 谢谢帮助!
    我要阳光3年前 (2021-06-03)回复
87 queries in 0.146 seconds, using 22.15MB memory