当前位置: 代码迷 >> 综合 >> ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。
  详细解决方案

ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。

热度:74   发布时间:2023-10-12 15:01:44.0

今天更新包的时候,提示我要升级pip。于是等升级完,打开PyCharm测试了一下新包的情况,便马不停蹄地更新pip了。

这下可好,应该是升级的时候忘记关PyCharm,导致pip被占用,于是出现以下报错:

ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'd:\\python\\scripts\\pip.exe'Consider using the `--user` option or check the permissions.

ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。

pip install --upgrade pip还是报错,跟之前情况(解决‘pip‘ is a package and cannot be directly executed报错问题和WinError 5]拒绝访问)类似,这一次丝毫不慌。

只不过这一次到d:\python\lib\site-packages,发现已经没有pip相关的两个文件夹了

C:\Users\dell>pip install --upgrade pip
Traceback (most recent call last):File "d:\python\lib\runpy.py", line 197, in _run_module_as_mainreturn _run_code(code, main_globals, None,File "d:\python\lib\runpy.py", line 87, in _run_codeexec(code, run_globals)File "D:\Python\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'

pip -v也没有反应

C:\Users\dell>pip -v
Traceback (most recent call last):File "d:\python\lib\runpy.py", line 197, in _run_module_as_mainreturn _run_code(code, main_globals, None,File "d:\python\lib\runpy.py", line 87, in _run_codeexec(code, run_globals)File "D:\Python\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'

 于是直接安装

python -m ensurepip
C:\Users\dell>python -m ensurepip
Looking in links: c:\Users\dell\AppData\Local\Temp\tmp30pelk6f
Requirement already satisfied: setuptools in d:\python\lib\site-packages (51.3.3)
Processing c:\users\dell\appdata\local\temp\tmp30pelk6f\pip-20.2.3-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-20.2.3

紧接着升级到最新版

python -m pip install --upgrade pip
C:\Users\dell>python -m pip install --upgrade pip
Collecting pipUsing cached pip-22.0.4-py3-none-any.whl (2.1 MB)
Installing collected packages: pipAttempting uninstall: pipFound existing installation: pip 20.2.3Uninstalling pip-20.2.3:Successfully uninstalled pip-20.2.3
Successfully installed pip-22.0.4

ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。

Yes! 

生信喵 X CSDN,记录debug的日常。

另外,欢迎大家关注公众号【生信喵】,在那里我会分享机器学习、算法开发的总结笔记……

  相关解决方案