简体   繁体   中英

Python venv returns error message. How to create a venv on windows

Every time I try to create a virtualenv for my Python project in VSCode and CommandPrompt using:

python -m venv venv

I get this error message:

Error: Command '['D:\\Coding Projects\\VS Code\\Ca$hTraCK\\venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 2.

I tried disabling and enabling python extension, upgrading pip version, but nothing works.

I don't know your python version, but if you're in Anoconda python, use command

python -m venv --without-pip venv

to create, cause Anoconda doesn't have ensurepip, then install pip after you activate the venv.

Also, python3.3 and higher version support venv module.

If the command doesn't work, it's recommended to reinstall python from [download]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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