首页 > 解决方案 > 在 Windows 上升级 Python 3.7 的 pip 但遇到权限错误

问题描述

我正在运行Win10 64位并尝试安装Python3.7并升级pip。

我将我的 Python 安装在 D:\python\python372-64 (并且在 python 文件夹中有其他版本的 python)。

Pip 应该与 Python 3 一起提供。当我运行时pip install pip --upgrade,它说Found existing installation: pip 18.1但是Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'd:\\python\\python372-64\\scripts\\pip.exe'. Consider using the '--user' option or check the permissions.'

所以我尝试以管理员身份运行,但它给了我以下错误:

Traceback (most recent call last):
File "d:\python\python372-64\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "d:\python\python372-64\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\Python\Python372-64\Scripts\pip.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'pip'

但是,如果我运行,python -m ensurepip我会得到:

Looking in links: C:\Users\jd\AppData\Local\Temp\tmpcww44m60
Requirement already satisfied: setuptools in d:\python\python372-64\lib\site-packages (40.6.2)
Collecting pip
Installing collected packages: pip
Successfully installed pip-18.1

另外,这是我的 PATH 环境变量:

D:\Python\Python372-64
D:\Python\Python372-64\Lib\site-packages\
D:\Python\Python372-64\Scripts

我应该怎么做才能解决这个问题?

标签: pythonpermissionsinstallationpipenvironment

解决方案


这解决了它!

py -3.72 -m pip install --upgrade pip


推荐阅读