在 Windows 升级 Python 3.7 的 pip 但遇到权限错误

Upgrade pip for Python 3.7 on Windows but encounter permission error

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

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

Pip 应该带有 Python 3. 当我 运行 pip install pip --upgrade 时,它说 Found existing installation: pip 18.1Could 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

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

这解决了!

py -3.72 -m pip install --upgrade pip