0

I'm using Ubuntu 20.04.4 LTS. When I try python3 -m venv env, I get:

The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
 
    apt install python3.8-venv
 
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
 
Failing command: ['/home/ubuntu/env/bin/python3', '-Im', 'ensurepip',
'--upgrade', '--default-pip']

Then I tried:

sudo apt-get update
sudo apt-get install python3.8-venv

and got this output

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python3.8-venv is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or is only
available from another source

E: Package 'python3.8-venv' has no installation candidate

If that package is not available any more, I want to know how can I be able to create a virtual environment (the package python3-pip is also missing, so pip is also not available).

The only way I could create a virtual environment is using conda, but I want to avoid that.

2
  • Have you messed with your Python installation? Perhaps tried changing your Python version or something? Apr 28, 2022 at 18:10
  • no it is a live cd with no changes to the system
    – nadapez
    Apr 28, 2022 at 18:56

2 Answers 2

2

Did you try using:

$ sudo apt-get install python3-venv

instead?

0
0

I also searched far and wide when I encountered this problem on my system (Ubuntu 22.04), and none of the suggested solutions worked for me, including:

The solution in my case was to (re-)enable the Ubuntu universe repository to be able to install python3-venv and related packages, as this was disabled on my machine.

In Ubuntu, this can be done by running the Software & Updates tool, which can also be opened by running:

software-properties-gtk

in the terminal, and then making sure the Community-maintained free and open-source software (universe) box is ticked (at least in Ubuntu 22.04).

It should prompt you to refresh, after which you can run sudo apt update and then sudo apt install python3-venv.

I hope this helps.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .