Score:2

Python3 and pip3 dependency issues on Ubuntu 22.04

cn flag

I have made a new, fresh installation of Ubuntu 22.04, on which I have also run sudo apt update and sudo apt upgrade.

Now I am trying to create a Python virtual env, but run into dependency issues, which I haven't been able to resolve. Running python3 -m venv myvenv asks me to run apt install python3.10-venv Doing so (with sudo, of course) I get this error:

Reading package lists... Done
Building dependency tree... Done
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.10-venv : Depends: python3.10 (= 3.10.4-3ubuntu0.1) but 3.10.6-1~22.04 is to be installed
                   Depends: python3.10-distutils
E: Unable to correct problems, you have held broken packages.

I have also tried sudo apt install python3-venv but that has similar problems with dependencies:

The following packages have unmet dependencies:
 python3-venv : Depends: python3.10-venv (>= 3.10.4-1~) but it is not going to be installed
                Depends: python3 (= 3.10.4-0ubuntu2) but 3.10.6-1~22.04 is to be installed
                Depends: python3-distutils (>= 3.9.10-2~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I have also tried to install pip, running sudo apt install python3-pip and get this conflict:

The following packages have unmet dependencies:
 python3-distutils : Depends: python3-lib2to3 (= 3.10.4-0ubuntu1) but 3.10.6-1~22.04 is to be installed
E: Unable to correct problems, you have held broken packages.

How can I get around these problems?


EDIT
As requested:
$ apt-cache policy python3.10-venv:
python3.10-venv:
  Installed: (none)
  Candidate: 3.10.4-3ubuntu0.1
  Version table:
     3.10.4-3ubuntu0.1 500
        500 http://archive.ubuntu.com/ubuntu jammy-security/universe amd64 Packages
     3.10.4-3 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
Olaf Dietsche avatar
cn flag
What is the reason for `apt update` and `apt upgrade` on a fresh install?
Olaf Dietsche avatar
cn flag
I just tried your commands in a Docker container, and cannot confirm these errors. There must be some other problems with your installation. Maybe search for the apt error: "E: Unable to correct problems, you have held broken packages.", e.g. https://askubuntu.com/search?q=E%3A+Unable+to+correct+problems%2C+you+have+held+broken+packages.
Rerun avatar
cn flag
It is good practice to run apt update before installing a package, and when I did so, it said that there were some upgrades available, so I installed them.
Olaf Dietsche avatar
cn flag
Yes, but on a fresh install everything should be up to date already. This was the reason for me being curious.
user535733 avatar
cn flag
Please [edit your question](https://askubuntu.com/posts/1434398/edit) to add the complete output of `apt-cache policy python3.10-venv`
Rerun avatar
cn flag
@user535733 Thank you. Updated.
Score:2
cn flag

Your apt-cache policy output shows that you don't have jammy-updates enabled.

  • Enable jammy-updates
  • Run sudo apt update

Then the version-related apt errors will vanish.

Rerun avatar
cn flag
Thank you for this! I have edited /etc/apt/sources.list and duplicated and uncommented the 3 lines that contain jammy-updates (main restricted, universe and multiverse) and changed the uncommented ones from "deb-src http:/archive..." to "deb http://archive...." and this did the trick. I see the difference in apt-cache policy now. Thank you very much.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.