LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   borked python upgrade (https://www.linuxquestions.org/questions/linux-software-2/borked-python-upgrade-4175716222/)

lvm_ 08-30-2022 02:50 AM

borked python upgrade
 
TL;DR - installed a newer version of python3. It fixed several things but broke several other things. How to make it all work?

Full version: ubuntu 18.04 - officially still supported, but canonical is doing a crappy job and python3 got so old than some programs started complaining. Installed the latest version 3.10 from https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa beside the existing 3.6 from the official repo and changed the /usr/bin/python3 link to point to /usr/bin/python3.10. Programs which were requiring something newer were satisfied, but it broke several things:

unknown command handling from bash no longer works

Code:

Traceback (most recent call last):
  File "/usr/lib/command-not-found", line 28, in <module>
    from CommandNotFound import CommandNotFound
  File "/usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py", line 19, in <module>
    from CommandNotFound.db.db import SqliteDatabase
  File "/usr/lib/python3/dist-packages/CommandNotFound/db/db.py", line 5, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

as well as some package handling stuff from cron

Code:

Aug 30 06:01:48 server apt.systemd.daily[2813]: Traceback (most recent call last):
Aug 30 06:01:48 server apt.systemd.daily[2813]:  File "/usr/bin/unattended-upgrade", line 32, in <module>
Aug 30 06:01:48 server apt.systemd.daily[2813]:    from gi.repository.Gio import NetworkMonitor
Aug 30 06:01:48 server apt.systemd.daily[2813]:  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
Aug 30 06:01:48 server apt.systemd.daily[2813]:    from . import _gi
Aug 30 06:01:48 server apt.systemd.daily[2813]: ImportError: cannot import name '_gi' from partially initialized module 'gi' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gi/__init__.py)

Aug 29 19:35:07 server dbus-daemon[1050]: [session uid=1000 pid=1048] Activating service name='org.kubuntu.DriverManager' requested by ':1.5' (uid=1000 pid=1422 comm="kded5 [kdeinit5]                                  " label="unconfined")
Aug 29 19:35:07 server org.kubuntu.DriverManager[1050]: Traceback (most recent call last):
Aug 29 19:35:07 server org.kubuntu.DriverManager[1050]:  File "/usr/lib/x86_64-linux-gnu/libexec/DriverManager_DBus", line 24, in <module>
Aug 29 19:35:07 server org.kubuntu.DriverManager[1050]:    import dbus
Aug 29 19:35:07 server org.kubuntu.DriverManager[1050]:  File "/usr/lib/python3/dist-packages/dbus/__init__.py", line 77, in <module>
Aug 29 19:35:07 server org.kubuntu.DriverManager[1050]:    import dbus.types as types
Aug 29 19:35:07 server org.kubuntu.DriverManager[1050]:  File "/usr/lib/python3/dist-packages/dbus/types.py", line 6, in <module>
Aug 29 19:35:07 server org.kubuntu.DriverManager[1050]:    from _dbus_bindings import (
Aug 29 19:35:07 server org.kubuntu.DriverManager[1050]: ModuleNotFoundError: No module named '_dbus_bindings'
Aug 29 19:35:07 server dbus-daemon[1050]: [session uid=1000 pid=1048] Activated service 'org.kubuntu.DriverManager' failed: Process org.kubuntu.DriverManager exited with status 1


Aug 29 19:35:07 server org.debian.AptXapianIndex[847]: Traceback (most recent call last):
Aug 29 19:35:07 server org.debian.AptXapianIndex[847]:  File "/usr/sbin/update-apt-xapian-index", line 66, in <module>
Aug 29 19:35:07 server org.debian.AptXapianIndex[847]:    import axi.indexer
Aug 29 19:35:07 server org.debian.AptXapianIndex[847]:  File "/usr/lib/python3/dist-packages/axi/indexer.py", line 31, in <module>
Aug 29 19:35:07 server org.debian.AptXapianIndex[847]:    import xapian
Aug 29 19:35:07 server org.debian.AptXapianIndex[847]:  File "/usr/lib/python3/dist-packages/xapian/__init__.py", line 24, in <module>
Aug 29 19:35:07 server org.debian.AptXapianIndex[847]:    from . import _xapian
Aug 29 19:35:07 server org.debian.AptXapianIndex[847]: ImportError: cannot import name '_xapian' from partially initialized module 'xapian' (most likely due to a circular import) (/usr/lib/python3/dist-packages/xapian/__init__.py)

I am not a python guru and in a bit of a loss - how can I transfer/install/index/convert/make available/whatever the stuff which works in 3.6 to 3.10? Note that all these errors are about the stuff installed in a shared /usr/lib/python3/dist-packages directory, not a version-specific site-packages. Or should I abandon the idea, create a separate environment for finicky programs and leave 3.6 as the default?

computersavvy 08-30-2022 05:22 PM

I find that when it is necessary to have more than one version loaded the use of the python virtual environment is a life saver.

With the major changes between 3.6 and 3.10 it seems likely that the system files may have conflicts, but a virtual environment install keeps the newly installed version isolated in the users home directory and does not conflict the same way 2 different versions installed in the system does.

How to do a virtual environment install (venv) is easy and instructions are found online very easily. https://docs.python.org/3/library/venv.html


All times are GMT -5. The time now is 02:00 PM.