Issue
This might be long but please bear with me till the end
When I tried to install python3-venv while following href="https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-programming-environment-on-ubuntu-20-04-quickstart" rel="nofollow noreferrer">this article
sudo apt install build-essential libssl-dev libffi-dev python3-dev
It threw the following error:
libffi-dev python3-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libffi-dev is already the newest version (3.3-4).
build-essential is already the newest version (12.8ubuntu1.1).
libssl-dev is already the newest version (1.1.1f-1ubuntu2.16).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python3-dev : Depends: libpython3-dev (= 3.8.2-0ubuntu2) but it is not going to be installed
Depends: python3.8-dev (>= 3.8.2-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
So instead of python3-dev
, I tried python3
only and it ran.
After that, I ran this command:
sudo apt install -y python3-venv
Then it gave me this:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python3-venv : Depends: python3.8-venv (>= 3.8.2-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
So I thought maybe I need to install python3.8-venv
, so I did:
sudo apt install -y python3.8-venv
AND, it gave me this error:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python3.8-venv : Depends: python3.8 (= 3.8.10-0ubuntu1~20.04.5) but 3.8.13-1+bionic2 is to be installed
E: Unable to correct problems, you have held broken packages.
THEN, I tried:
sudo apt install -y python3.8
which was fine and gave me this
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3.8 is already the newest version (3.8.13-1+bionic2).
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
I don't know what to do, my virtual env isn't working, I read somewhere that it's pre-installed so I also tried directly creating a virtual env with
python3 -m venv myEnv
Which again gave me this:
Error: Command '['/home/yash/Desktop/DashMed/myEnv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
which upon googling said to install python3-venv which I've already failed in
SO I AM STUCK IN THIS LOOP
PLEASE HELP
Solution
The main reason for these issues was the version of python3.8
I had version 3.8.13-1+bionic2
but we needed 3.8.10-0ubuntu1~20.04.5
I think this generally occurs when you upgrade from Ubuntu 18.04 LTS to Ubuntu 20.04 LTS using in-built Software & Updates
So I found this command which rolled back the versions now everything works fine
sudo apt install libpython3.8:amd64=3.8.2-1ubuntu1 libpython3.8-dev:amd64=3.8.2-1ubuntu1 libpython3.8-minimal:amd64=3.8.2-1ubuntu1 libpython3.8-stdlib:amd64=3.8.2-1ubuntu1 python3.8=3.8.2-1ubuntu1 python3.8-minimal=3.8.2-1ubuntu1
After this, all those other commands ran perfectly on my system
I found this rollback command here
Answered By - Yash Joglekar Answer Checked By - Clifford M. (WPSolving Volunteer)