Knogle
Posts: 5
Joined: Fri Sep 18, 2020 9:16 pm

Not able to install Python anymore

Wed May 05, 2021 8:20 pm

Ahoy ahoy friends.
I got a fresh installed Raspberry OS build, using the latest Lite image, and "buster" release branch.
I have installed python, and my applications requiring python.
Now, after having updated all packages and running dist-upgrade, python seems to be broken, and i am not able to fix it anymore.
I have removed all python packages already, but when i try to reinstall it's not possible to resolve these dependencies.
Last time when this problem occured, i had to manually get all the dependencies from the mirrors, but is there a simple way to fix this?

Thanks in advance!

Code: Select all

root@raspberrypi:/usr/local/bin/rpisurv# apt-get install -f --reinstall python
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:
 python : PreDepends: python-minimal (= 2.7.16-1) but it is not going to be installed
          Depends: libpython-stdlib (= 2.7.16-1) but it is not going to be installed
          Depends: python2 (= 2.7.16-1) but 2.7.18-2 is to be installed
E: Unable to correct problems, you have held broken packages.

gordon77
Posts: 5682
Joined: Sun Aug 05, 2012 3:12 pm

Re: Not able to install Python anymore

Wed May 05, 2021 8:41 pm

Doesn't lite come with python installed ?

User avatar
B.Goode
Posts: 12081
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Not able to install Python anymore

Wed May 05, 2021 9:01 pm

gordon77 wrote:
Wed May 05, 2021 8:41 pm
Doesn't lite come with python installed ?


Certainly does...


Python[2] v2.7.16 and Python3 v3.7.3 have been installed by default in all releases of RasPiOS Buster [32] 'Lite' since June 2019.


So @knogle - what did you think was 'broken' that might be 'fixed' by the steps you have taken? Perhaps there is another way to solve the problem?

Knogle
Posts: 5
Joined: Fri Sep 18, 2020 9:16 pm

Re: Not able to install Python anymore

Wed May 05, 2021 9:52 pm

Well, so seems like my updates have broken python somehow, because as you said it has worked initially.
So what is the best way to go now? Flash a new image and put the python packages and its dependencies on hold?

In conclusion I am not able to recover my python into a working state, having the latest packages installed.

After having updated all the stuff, /usr/bin/python wasn't available anymore.

MiscBits
Posts: 249
Joined: Wed Jan 27, 2021 12:48 pm

Re: Not able to install Python anymore

Wed May 05, 2021 10:19 pm

I would start from scratch again :-)

The /usr/bin/python program is the older V2 and should not really be used anymore as it's on its way out.

Unless you have a very very specific need for a given version stick with the version shipped and just use virtual environments for modules.
Is a computer language with goto's totally Wirth-less?

User avatar
scruss
Posts: 4094
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: Not able to install Python anymore

Thu May 06, 2021 12:42 am

also try:

Code: Select all

sudo apt-get install --fix-broken
Did you change any of the files in /etc/apt? What did you do to get to this place?
The reason I ask is that your system wants to install python2 2.7.18-2, but the latest available version is 2.7.16-2. Did you perhaps add a Debian or Ubuntu repo by mistake?
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Knogle
Posts: 5
Joined: Fri Sep 18, 2020 9:16 pm

Re: Not able to install Python anymore

Thu May 06, 2021 6:45 am

My /etc/apt/sources.list looks like that

Code: Select all

deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

User avatar
B.Goode
Posts: 12081
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Not able to install Python anymore

Thu May 06, 2021 7:08 am

Knogle wrote:
Thu May 06, 2021 6:45 am
My /etc/apt/sources.list looks like that

Code: Select all

deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

That looks 'normal' for an installation of RasPiOS Buster.

Are there any files in /etc/apt/sources.list.d ? If so, what do they contain?


But to repeat a couple of points:

Unless you have some specific reason not to, Python3 is the version of the language (and interpreter) recommended for new projects.

The version of Python3 installed by default in RasPiOS Buster, including the Lite variant, is the most up-to-date available in a supported fashion for the Debian distribution of linux on which RasPiOS is based.


Why do you need to make any change to the version provided by RasPiOS?

User avatar
RaspbianUser1
Posts: 841
Joined: Thu Mar 05, 2020 6:34 pm
Location: ~/

Re: Not able to install Python anymore

Sat May 08, 2021 1:17 pm

Uninstalling Python is a terrible idea, there are many software and services which rely on it,

You can compile the newest version from the python website, however I wouldn't recommend it since you will have errors with things like pip.

Also what is wrong with the current versions of python, they are perfectly fine, and anyway when Debian 11 Bullseye comes out, we will have access to newer stable versions
Running with a Raspberry Pi 4B 4GB with Raspberry Pi OS with MATE Desktop
Why not overclock, push some more performance out of your computer!
Think before you delete something a stranger on the internet told you to.

Return to “Raspberry Pi OS”