在Windows中升级virtualenv中的pip错误



我正在创建这样一个虚拟环境:

$ py -m venv venv

然后激活它(我使用Powershell):

> venv/Scripts/activate

现在我运行:

(venv) PS D:/...> pip install -U pip
Requirement already satisfied: pip in d:azureapp-registrationms-identity-python-webappvenvlibsite-packages (21.1.1)
Collecting pip
Downloading pip-22.3.1-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 1.3 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.1.1
Uninstalling pip-21.1.1:
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'd:\..\venv\scripts\pip.exe'
Check the permissions.

为什么会这样?

这是因为您的操作系统没有允许创建虚拟环境。

你可以通过打开powershell administrative然后粘贴这个

来解决这个问题
Set-ExecutionPolicy unrestricted

然后按回车

之后选择Yes To All

然后重新启动ide

必须解

最新更新