简体   繁体   English

在虚拟环境中安装 pip 的问题

[英]Problem with installing pip in virtual enviroment

Im trying to make a virtual enviroment in vs code with this command in powershell:我试图在 powershell 中使用此命令在 vs 代码中创建虚拟环境:

py -3 -m venv venv

But i get this error message:但我收到此错误消息:

Error: Command '['C:\\Users\\Oscar GP\\lololol\\venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.

This makes the enviroment, but in the Scripts folder it doesn't make a activate file.这创建了环境,但在 Scripts 文件夹中它没有创建激活文件。 but with this command it makes all the right files:但是使用这个命令它会生成所有正确的文件:

virtualenv venv

But with that command, it wont activate the venv correctly, and i cant fx use:但是使用该命令,它不会正确激活 venv,我不能使用:

pip install flask

if i try installing flask, then i get this error message:如果我尝试安装 flask,则会收到此错误消息:

Unable to create process using 'C:\Users\Oscar GP\AppData\Local\Programs\Python\Python310\python.exe "C:\Users\Oscar GP\lololol\venv\Scripts\pip.exe" install flask'

I have latest versions of python and pip. I've tried uninstalling and reinstalling python and i tried the same commands in cmd and powershell.我有最新版本的 python 和 pip。我尝试卸载并重新安装 python,我在 cmd 和 powershell 中尝试了相同的命令。

If it matters execution policy is also unrestricted.如果重要的话,执行政策也是不受限制的。

Anyone knows how to fix this?任何人都知道如何解决这个问题?

After doing a little research, it seems there are a couple of reasons this may occur.在做了一些研究之后,似乎有几个原因可能会发生这种情况。 However, someone else seems to have had the most similar problem here before.但是,其他人似乎以前在这里遇到过最相似的问题。 This may occur after upgrading python versions, in which case run sudo apt install python3.{new_version}-venv where new_version is the latest version of python on your system (or whichever version you are using to develop).这可能发生在升级 python 版本后,在这种情况下运行sudo apt install python3.{new_version}-venv其中new_version是您系统上 python 的最新版本(或您用于开发的任何版本)。 Another possible listed solution was to uninstall python, then reinstall, and make sure to click the install for all users option.另一个可能列出的解决方案是卸载 python,然后重新安装,并确保单击为所有用户安装选项。 The last likely solution is to run the command python -m venv --clear --symlinks./venv to recreate your vent.最后一个可能的解决方案是运行命令python -m venv --clear --symlinks./venv来重新创建你的通风口。 Hope one of these works out:).希望其中一个可行:)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM