Ubuntu Support Template
Ubuntu Version:
24.04 LTS
Desktop Environment (if applicable):
GNOME
Problem Description:
System issue after remove default python (3.12) on Ubuntu Dekstop 24.04 LTS,
and im update to 3.11 using PPA , & update manually build using official site 3.13.9 (https://www.python.org/ftp/python/3.13.9/Python-3.13.9.tgz)
AI (chat GPT,Gemma3, Deepseek R1, ETC) cant solved my problem
help me
sudo apt update
Hit:1 http://id.archive.ubuntu.com/ubuntu noble InRelease
Hit:2 https://download.docker.com/linux/ubuntu noble InRelease
Hit:3 http://id.archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:4 http://id.archive.ubuntu.com/ubuntu noble-backports InRelease
Hit:5 https://nvidia.github.io/libnvidia-container/stable/deb/amd64 InRelease
Hit:6 https://deb.nodesource.com/node_22.x nodistro InRelease
Hit:7 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:8 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu noble InRelease
Hit:9 https://pkg.cloudflare.com/cloudflared any InRelease
Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 3, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
Reading package lists... Done
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://deb.nodesource.com/node_22.x nodistro InRelease' doesn't support architecture 'i386'
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'https://pkg.cloudflare.com/cloudflared any InRelease' doesn't support architecture 'i386'
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code
stackoverflow*com/questions/56218562/how-to-fix-modulenotfounderror-no-module-named-apt-pkg
sudo apt-get install --reinstall python3-apt
sudo apt-get install --reinstall python3-commandnotfound
sudo apt-get install python3.11
sudo apt-get install python3.12
root@VM-RND-001:~# ls -l /usr/lib/python3/dist-packages/apt_pkg.*
lrwxrwxrwx 1 root root 70 Oct 25 18:48 /usr/lib/python3/dist-packages/apt_pkg.cpython-311-x86_64-linux-gnu.so -> /usr/lib/python3/dist-packages/apt_pkg.cpython-312-x86_64-linux-gnu.so
-rw-r--r-- 1 root root 347328 Jul 25 22:23 /usr/lib/python3/dist-packages/apt_pkg.cpython-312-x86_64-linux-gnu.so
lrwxrwxrwx 1 root root 70 Nov 9 20:46 /usr/lib/python3/dist-packages/apt_pkg.cpython-313-x86_64-linux-gnu.so -> /usr/lib/python3/dist-packages/apt_pkg.cpython-312-x86_64-linux-gnu.so
root@VM-RND-001:~# python3 -c "import apt, apt_pkg; print('APT OK')"
Traceback (most recent call last):
File "<string>", line 1, in <module>
import apt, apt_pkg; print('APT OK')
^^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'apt'
only one can be fixed, but just py3compile to change 3.13.9
mv /usr/bin/py3compile /usr/bin/py3compile.orig
ln -s $(which true) /usr/bin/py3compile
still not solve the problem
python list
root@VM-RND-001:~# sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/local/bin/python3.13 2 auto mode
1 /usr/bin/python3.11 1 manual mode
* 2 /usr/local/bin/python3.13 2 manual mode
Press <enter> to keep the current choice[*], or type selection number: ^C
root@VM-RND-001:~# sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/local/bin/python3.13 2 auto mode
1 /usr/bin/python3.11 1 manual mode
* 2 /usr/local/bin/python3.13 2 manual mode
Press <enter> to keep the current choice[*], or type selection number: ^C