0

My System-info

  • Running Ubuntu Desktop(22.04.1 LTS) from a USB stick
  • Base Machine Windows 11
  • Python version on Ubuntu is 3.10.4

Trying to create a python virtual environment

python3 -m venv .

Getting error

    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.10-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: ['/media/ubuntu/New Volume/myWorks/Ubuntu/DALLE_Project/vnv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']

When running the above command

sudo apt install python3.10-venv

Getting below error

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package python3.10-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.10-venv' has no installation candidate

Getting same above error for sudo apt install python3-venv also.

Any suggestion to troubleshoot?

Chinmay Nayak
  • 203
  • 5
  • 17

1 Answers1

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.