On Windows, if you try to use pip to upgrade itself, inside a virtualenv, you may get a mysterious "access is denied" error. For instance:
D:\scratch\> C:\Program Files\Python\3.7.4\x64\python.exe -m venv D:\scratch\my-venv D:\scratch\> D:\scratch\my-venv\Scripts\activate (my-venv) D:\scratch\> pip install --upgrade pip Collecting pip Downloading pip-19.3.1-py2.py3-none-any.whl (1.4MB) Installing collected packages: pip Found existing installation: pip 19.0.3 Uninstalling pip-19.0.3: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'd:\\scratch\\my-venv\\scripts\\pip.exe' Consider using the `--user` option or check the permissions. This happens whether or not the command prompt has administrative privileges. We know we have write access to everything inside d:\scratch\my-venv, because we just created it with the initial python -m venv command. The advice to use the --user option is unhelpful, since we want to upgrade the version of pip inside the virtualenv, which --user will not do.
What could be wrong, and what is the correct way to upgrade pip inside a virtualenv on Windows?