We Are Going To Discuss About Error when creating venv, Error: Command ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1. So lets Start this Python Article.
Error when creating venv, Error: Command ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1
- How to solve Error when creating venv, Error: Command '-Im', 'ensurepip', '–upgrade', '–default-pip']' returned non-zero exit status 1
On Ubuntu first, install the venv of the specific python version
sudo apt install python3.9-venv
python3.9 -m venv myenv
//specify the python version. This will create the virtual env “myenv” - Error when creating venv, Error: Command '-Im', 'ensurepip', '–upgrade', '–default-pip']' returned non-zero exit status 1
On Ubuntu first, install the venv of the specific python version
sudo apt install python3.9-venv
python3.9 -m venv myenv
//specify the python version. This will create the virtual env “myenv”
Solution 1
On Ubuntu first, install the venv of the specific python versionsudo apt install python3.9-venv
python3.9 -m venv myenv
//specify the python version. This will create the virtual env “myenv”
Original Author AYESIGYE DERRICK Of This Content
Solution 2
I am using windows 10 WSL2 ubuntu 20.04, sudo
resolved my problem.
sudo python3.8 -m venv venv
Original Author j3rry Of This Content
Solution 3
1- head over this doc and try to refix your global python installation accordingly, don’t forget to check Install launcher for all users
option, after successful installation the py launcher
will be localed under C:\Windows
folder.
2- use isolated vrtual environement, venv
built-in module is recommended over other 3rd tools and just avoid to mess with your global python folder.
PS c:\YOUR_PROJECT_FOLDER> py --version
PS c:\YOUR_PROJECT_FOLDER> py -0p # many python version (3.8.x, 3.9.X, 3.10.x ..) can co-exist without any conflict
PS c:\YOUR_PROJECT_FOLDER> py -m venv venv
PS c:\YOUR_PROJECT_FOLDER> .\venv\Scripts\activate
(venv) PS c:\YOUR_PROJECT_FOLDER> pip list
Package Version
---------- -------
pip 20.2.3
setuptools 49.2.1
WARNING: You are using pip version 20.2.3; however, version 21.3 is available.
You should consider upgrading via the 'c:\users\USER\desktop\YOUR_PROJECT_FOLDER\venv\scripts\python.exe -m pip install --upgrade pip' command.
# Here just copy/past that link to update the local pip of your virtual environment
(venv) PS c:\YOUR_PROJECT_FOLDER> c:\users\USER\desktop\YOUR_PROJECT_FOLDER\venv\scripts\python.exe -m pip install --upgrade pip
Collecting pip
Using cached pip-21.3-py3-none-any.whl (1.7 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.2.3
Uninstalling pip-20.2.3:
Successfully uninstalled pip-20.2.3
Successfully installed pip-21.3
(venv) PS c:\YOUR_PROJECT_FOLDER> pip list
Package Version
---------- -------
pip 21.3
setuptools 49.2.1
(venv) PS c:\YOUR_PROJECT_FOLDER> pip install <PYTHON_PACKAGE>
Original Author cizario Of This Content
Solution 4
This has something to do with the Windows update.
PS C:\Users\Your Name\AppData\Local\Programs\Python\Python38> ./python -m venv c:\TEMP\py38-venv
Error: Command '['c:\\TEMP\\py38-venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.
This will fix the issue:
- Uninstall Python.
- Install with the Custom option.
- Use the “Install for all users”.
After this it worked fine:
PS C:\Utilities\PythonBase\Python38> .\python -m venv c:\temp\venv-py38
PS C:\Utilities\PythonBase\Python38>
Original Author kinshukdua Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.