Search code examples
pythonvirtual-environment

cannot create python virtual environment (exit status 101)


When I try to generate a virtual environment, the following error pops up on Windows 11:

PS C:\programming\tmp> python -m venv venv
Error: Command '['C:\\programming\\tmp\\venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.

I have uninstalled all versions of python I did reinstall python 3.10.1 but the error remains. Based on this post I did try to install it for all users with no success. I also added python to PATH.

My guess is that it is related to pip, since python -m venv --without-pip venv_no_pip works (but I need pip thus this is no good solution).

I would appreciate any hint on what to do since I'm out of ideas.


Solution

  • I encountered the same problem (well, all users install did work on my PC) and found a solution. If your python is installed on a path with a space, check out my self-answer