'Python3.8 venv returned exit status 101

I found similar posts, mostly related to linux on venv having an issue with working. python 3.8 venv missing activate command However, I am confused on how to solve it on windows, and what is happening.

I installed python3.8 from downloading it on pythons website. Then I follow the 3.8 documentation https://docs.python.org/3/library/venv.html which shows:

python3 -m venv /path/to/new/virtual/environment

I do this but then get the following error:

Error: Command '['E:\\py_envs\\hf4\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.

When I use: python -m venv --without-pip hf4

and then hf4\Scripts\activate

It works for activation. What I don't understand is that I can then run pip and it is there during the activated environment. It seems a maybe related issue, is that anything I have installed on my system python is also available. For example, in the activated session:

(hf4) E:\py_envs>where pip
C:\Users\local user\AppData\Local\Programs\Python\Python38\Scripts\pip.exe

One question is naturally how to fix this, the other is that I would appreciate an explanation as to what is happening to better understand it. Does it search first for the active environment, and if it can't find it, defaults to a system version?



Solution 1:[1]

Thanks. I faced the same issue and this thread worked around for me. I uninstalled Python and installed 3.9. Python version (which was available for me at the time) checking "Install for all users" in advanced installing. Remember to check "Add the PATH" box so that you can run Python from the command prompt.

Solution 2:[2]

I unistall all newest version and reinstall python 3.7.9 checking "install for all users" option on instalation, try again to create a project.

Solution 3:[3]

I encountered the same problem and found a reason and a solution. If your python is installed on a path with a space, what I found out likely explains your case as well (which nobody really explained to you above). Check out my self-answer to my question. There is one remaining question, however, which is how this sensitivity to the space started all of a sudden, but this fix worked for me.

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Jonatas Aguiar
Solution 2 Navas Ema
Solution 3 kesh