1.在更新python虚拟环境pip版本时,报错
(ven) D:\virtualenv\ven\Scripts>pip install --upgrade pip
Collecting pip
Using cached pip-24.0-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.1.1
Uninstalling pip-20.1.1:
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'd:\\virtualenv\\gpt\\scripts\\pip.exe'
Consider using the --user option or check the permissions.
2. 重新查看时pip丢失
(ven) D:\virtualenv\ven\Scripts>pip list
Traceback (most recent call last):
File "D:\python3.7\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "D:\python3.7\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\virtualenv\gpt\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'
3. 重新安装pip
方法1:使用get-pip.py重新安装pip
下载get-pip.py
脚本:打开 https://bootstrap.pypa.io/get-pip.py
下载脚本。保存文件到你方便找到的位置。
运行python get-pip.py
重新安装pip:
方法2:在虚拟环境中安装pip
激活虚拟环境:
D:\virtualenv\ven\Scripts\activate
安装pip:
python -m ensurepip --upgrade