1

Whenever I try to create virtual environment in python I get this error

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

I am using Windows 10. I tried uninstalling python and reinstalled it several times but still the problem continues.

I have been using python on my computer from years but now I am facing this error.

markwalker_
  • 12,078
  • 7
  • 62
  • 99
sha
  • 7
  • 1
  • 4
  • Maybe worth ensuring you have the "install for all users" option selected. Refer to the answer here; https://stackoverflow.com/a/62207756/1199464 – markwalker_ Jun 26 '22 at 19:24
  • I selected that option as well but still its not working – sha Jun 27 '22 at 06:24

3 Answers3

0

just delete your current python directory and reload it again from official web page enter link description here

0

I got a similar error when I already had a venv folder in my current working folder. See if you have one.. if you do delete it and try again and it should work.

Might need to go to view-command pallette-select intepreter- then select python venv if using vscode after the first step.

John Carr
  • 69
  • 3
0

I had this issue on a redhat server while trying to make a python venv as a non-root user.

Here is a detailed output on why the venv creation fail.

$ python-venv/bin/python3 -Im ensurepip --upgrade --default-pip
Traceback (most recent call last):
  File "/usr/lib64/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/usr/lib64/python3.6/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/usr/lib64/python3.6/runpy.py", line 109, in _get_module_details
    __import__(pkg_name)
  File "/usr/lib64/python3.6/ensurepip/__init__.py", line 21, in <module>
    _SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
  File "/usr/lib64/python3.6/ensurepip/__init__.py", line 18, in _get_most_recent_wheel_version
    return str(max(versions, key=distutils.version.LooseVersion))

I don't have a mean to verify if the python installation is correct, but I assume it isn't.

Adrades
  • 1
  • 1