12

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.

SultanOrazbayev
  • 14,900
  • 3
  • 16
  • 46
anjana_dodampe
  • 121
  • 1
  • 1
  • 6

4 Answers4

6

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

sudo apt install python3.9-venv

should solve the issue

half of a glazier
  • 1,864
  • 2
  • 15
  • 45
  • same, I had python 3.6 in my Ubuntu, and I installed 3.9, and then when I tried creating a new environment I ran into this error and your solution worked – Singh Nov 28 '21 at 14:41
6

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
Mattwmaster58
  • 2,266
  • 3
  • 23
  • 36
5

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

tttjj
  • 346
  • 2
  • 9
-2

I also faced the same problem after upgrading to python 3.9.2 "Error: Command '['C:\Users\Chicool Ph G\PycharmProjects\InvenoryTrackingSystem\venv\Scripts\python.exe', '-Im', 'ensurepip', '--upgrade', '--default- pip']' returned non-zero exit status 101"

It worked;

  1. unistall the Python 3.9.2
  2. reinstall the Python 3.9.2
  3. Select Custom install
  4. Check(Tick) install for all users
  5. Click install