Search code examples
pythonpermissionsinstallationpipenvironment

Upgrade pip for Python 3.7 on Windows but encounter permission error


I'm running Win10 64bit and try to install Python3.7 and upgrade pip.

I install my Python at D:\python\python372-64 (and have other versions of python within the python folder).

Pip should come with Python 3. When I run pip install pip --upgrade, it says Found existing installation: pip 18.1 but 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.'

So I try to run as an administrator, but it gives me the following error:

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'

However, if I run python -m ensurepip I get this:

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

Also, here are my environment variables for PATH:

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

What should I do to resolve this?


Solution

  • This solved it!

    py -3.72 -m pip install --upgrade pip