I try to create a virtual environment to let me install NumPy, SciPy and Matplotlib
I write this: python3.8 -m venv work3.8
and the result was: Error: Command '['/home/mohammed/work3.8/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

- 11
- 1
- 2
-
Try [this solution](https://stackoverflow.com/questions/24123150/pyvenv-3-4-returned-non-zero-exit-status-1), I think you have a same problem. – CuCaRot Aug 11 '20 at 10:16
-
it gives another errors – Mohammed Aldhanuna Aug 11 '20 at 10:42
2 Answers
Probably you got the message because the venv package is not present on your system for python3.8
or that you need sudo
before the command.
Solve it by installing the venv package for python3.8
:
apt install python3.8-venv
Then create a new venv virtual environment:
python3.8 -m venv ~/.venvs/work3.8
The above assumes that inside your home directory, you have previously created a directory called .venv
, inside of which the venv virtual environments will be stored. If not, it can be created with mkdir ~/.venv
You might need to prepend sudo
to the commands, depending on what privileges your user has, like so:
sudo apt install python3.8-venv
sudo python3.8 -m venv ~/.venvs/work3.8

- 1,163
- 10
- 19
Please try: python3 -m venv [your directory]
After that, if you want to use your new virtual enviroment type: source [your directory]/bin/activate
Then if you want to leave your venv type: deactivate
(checked on Debian)
I hope that this helps you, Kind regards

- 1,391
- 8
- 14

- 11
- 4
-
-
I write" "python3 -m venv [your directory]" then: " source[mohammed]/bin/activate" and the result is: "bash: source[mohammed]/bin/activate: No such file or directory" – Mohammed Aldhanuna Aug 11 '20 at 11:13
-
Hello Mohammed, We create an example folder that will contain our virtual enviroment (venv)
myuser@mypc:~$ mkdir example
– MAInformatico Aug 11 '20 at 11:13myuser@mypc:~/example$ mkdir venv Now we create the virtual enviroment inside venv folder:
myuser@fmypc:~/example$ python3 -m venv venv Now we activate the virtual enviroment:
myuser@mypc:~/example$ source venv/bin/activate Now the new virtual enviroment is activated: (venv) myuser@mypc:~/example$ If we want to leave it just type:
(venv) myuser@mypc:~/example$ deactivate
-
The [] means that you need to write the directory where you want to create the virtual enviroment: for example if you want to create the virtualenviroment on the path: /home/mohammed/example You need you text: ```python3 -m venv /home/mohammed/example``` Do not use the "" please – MAInformatico Aug 11 '20 at 11:16