'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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source