Python on Ubuntu 18.04.4: command returned non-zero exit status 1

Viewed 3078

Ok, let's start by saying that I'm an absolute beginner in programming, and I wanted to start from Python. I've learned the very basics and I read that it's best to create a virtual environment when working on a project. Since I have three Python versions, 2.something, 3.6.9 and 3.8.2, and I wanted to use the latest version, I used the following command:

python3.8 -m venv env

And it gives me this message, which I don't really understand:

Error: Command '['/home/robert/python/python_p/env/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

But the environment is actually created. Nonteheless, when I try to work in the environment by using

source env/bin/activate

It gives me this:

bash: env/bin/activate: No such file or directory

The important thing here is that if I use the

python3 -m venv

command it works just fine, but it sets the 3.6.9 version by default, which I don't want to use. I know I can change it later, but it has become personal.

1 Answers

I believe the error is due to not having a python3.8-venv package installed.

Error: Command '['/home/robert/python/python_p/env/bin/python3.8', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

You can try the following

$ rm -rf venv
$ apt install python3.8-venv
...
$ python3.8 -m venv venv
... success

You may also find this useful

Related