windows 系統上進行 pip 包安裝時遇到許可權錯誤,提示拒絕訪問 ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒絕訪問

萧帅發表於2024-11-20

報錯描述
在 windows 系統終端命令視窗中用 pip 指令安裝包時報錯,需要升級 pip 來解決問題。在執行 pip install --upgrade pip 後,報出如下錯誤:

C:\Users\Administrator>pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl
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] 拒絕訪問。: 'd:\python37\scripts\pip.exe'
Consider using the --user option or check the permissions.

解決方法
1、輸入如下修復程式碼:
python -m ensurepip

2、重新更新升級 pip:
python -m pip install --upgrade pip

文獻來源:https://blog.csdn.net/qq_42711123/article/details/130565432

相關文章