Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Returned non zero exit status 101 giving an error when I tried create a Virtual environment

When I run py -3 -m venv venv on command prompt to create a virtual environment it fails.

"Error: Command '['C:\\Users\\Guest\\Desktop\\Python Web 
 App\\venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default- 
 pip']' returned non-zero exit status 101. 

How to fix this? I've installed the latest Python Version. I'm stuck here on my way to set up Flask for web development.

like image 941
anjana_dodampe Avatar asked Apr 22 '20 17:04

anjana_dodampe


People also ask

How do I enable virtual environment in Python?

To use the virtual environment you created to run Python scripts, simply invoke Python from the command line in the context where you activated it. For instance, to run a script, just run python myscript.py .

Where is Virtualenv installed?

If you try to run virtualenv and find it isn't present, you can install it using pip. virtualenv.exe will likely now be found in your python installation directory under the Scripts subdirectory.

How do I escape virtual env?

You can exit from the virtualenv using exit command, or by pressing Ctrl+d.

Is VENV the same as Virtualenv?

These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.


3 Answers

This happened after I upgraded from python3.8 to python3.9.

sudo apt install python3.9-venv

should solve the issue

like image 168
half of a glazier Avatar answered Oct 21 '22 10:10

half of a glazier


I had this problem - the workaround was to uninstall Python and reinstall it with the Install for all users option. See my longer answer: https://stackoverflow.com/a/62207756/11308690

like image 34
tttjj Avatar answered Oct 21 '22 11:10

tttjj


I tried reinstalling python to no avail. This problem seems to occur when copying the python executable doesn't work (fully) for whatever reason (seems to be related to PyCharm). I recreated my venv with the --clear --symlinks:

python -m venv --clear --symlinks ./venv
like image 4
Mattwmaster58 Avatar answered Oct 21 '22 10:10

Mattwmaster58