Apt get python error

apt-get install/remove/reinstall doesn’t work. Python errors

Recently I tried to install the ubuntu desktop on my ubuntu server 14. The installation failed hard. I tried several things fixing it and did a lot of research. But I couldn’t find anything helpful. This is the output when i try to reinstall ubuntu-desktop. http://pastebin.com/60TM3ePn

Please put only relevant information in your question or else no one will be able to answer. If you do not know what is relevant and what is not, better put the information somewhere else and share the link to that file in your question

I tried to install the ubuntu-drivers-common module manually. I Downloaded the .deb file of the module and started the package installer with it. It did not work. After that I tried extracting the .deb File and ran the .sh scripts for installing. Got the same errors.

2 Answers 2

run the following commands:

sudo apt-get clean sudo apt-get update sudo apt-get install --reinstall ubuntu-drivers-common/$(lsb_release -c -s) python3-update-manager/$(lsb_release -c -s) update-manager/$(lsb_release -c -s) 

if that doesn’t work, try this:

sudo dpkg -P ubuntu-drivers-common sudo dpkg -P python3-update-manager sudo dpkg -P update-manager sudo apt-get clean sudo apt-get update sudo apt-get install --reinstall ubuntu-drivers-common update-manager python3-update-manager sudo apt-get install --reinstall ubuntu-desktop/$(lsb_release -c -s) sudo apt-get dist-upgrade 

Thanks. But it did not solve the problem. ` dpkg -P ubuntu-drivers-common dpkg: error processing package ubuntu-drivers-common (—purge): package is in a very bad inconsistent state; you should reinstall it before attempting a removal Errors were encountered while processing: ubuntu-drivers-common ` got the same error with the update-manager.

Читайте также:  Java округление при делении

The python3-update-manager has dependency problems. «apt-get clean» and «apt-get update» also fails. I get the same python errors as always. Also the Reinstallation of the two modules fail the same way with the same errors. They all drop the python errors in [link]pastebin.com/60TM3ePn .

@NumericError the problem is that you are trying to install packages from the wrong distro and so they are not available throught the package manager for your distro. Did you run the first three commands? if so, and if they installed, you should NOT try to purge the packages you just installed. Go ahead and run the first three commands again DO NOT run the dpkg -P commands and please report any errors.

I fixed it myself. I set up a Ubuntu server VM (The exact same Ubuntu server version and so on). Then I copied /usr/lib/python3.4/* from the vanilla ubuntu server via ftp on my other server with the problems. On this system i moved /usr/lib/python3.4/* in a temp folder. After that i put in the vanilla python3.4 folder in the /usr/lib/python3.4 folder. Then I copied the old python3.4 (the one in the temp folder) over the /usr/lib/python3.4 folder.

So I simply replaced the old python3.4 with the new. And then copied the old over the new.

After all that I ran apt-get -f install . I got a lot of errors. They all told me that my python3.4 was not configured jet.

So I ran apt-get —reinstall install python3 . It worked fine.

At the end I ran «apt-get -f install» again and it installed every Broken package fine and everything was beautiful correct. 😀

I know it is not a really smart way to solve it though. And sure not something I would recommend. But well, if you are desperate enough.

Источник

Cannot install ANY packages because of Python

I cannot install any packages with apt-get on Raspbian (Debian) because of stupid Python packages. I tried to sudo dpkg —configure -a but even then I’m getting these errors! Messages:

Setting up python3 (3.4.2-2) . running python rtupdate hooks for python3.4. dpkg-query: package 'gdebi-core' is not installed Use dpkg --info (= dpkg-deb --info) to examine archive files, and dpkg --contents (= dpkg-deb --contents) to list their contents. Traceback (most recent call last): File "/usr/bin/py3clean", line 210, in main() File "/usr/bin/py3clean", line 196, in main pfiles = set(dpf.from_package(options.package)) File "/usr/share/python3/debpython/files.py", line 53, in from_package raise Exception("cannot get content of %s" % package_name) Exception: cannot get content of gdebi-core error running python rtupdate hook gdebi-core dpkg-query: package 'python3-uno' is not installed Use dpkg --info (= dpkg-deb --info) to examine archive files, and dpkg --contents (= dpkg-deb --contents) to list their contents. Traceback (most recent call last): File "/usr/bin/py3clean", line 210, in main() File "/usr/bin/py3clean", line 196, in main pfiles = set(dpf.from_package(options.package)) File "/usr/share/python3/debpython/files.py", line 53, in from_package raise Exception("cannot get content of %s" % package_name) Exception: cannot get content of python3-uno error running python rtupdate hook python3-uno dpkg: error processing package python3 (--configure): subprocess installed post-installation script returned error exit status 4 dpkg: dependency problems prevent configuration of python3-gi: python3-gi depends on python3 (>= 3.4~); however: Package python3 is not configured yet. python3-gi depends on python3 (= 3.2.3-3~); however: Package python3 is not configured yet. python3-software-properties depends on unattended-upgrades; however: Package unattended-upgrades is not configured yet. dpkg: error processing package python3-software-properties (--configure): dependency problems - leaving unconfigured dpkg: dependency problems prevent configuration of dh-python: dh-python depends on python3:any (>= 3.3.2-2~); however: Package python3 is not configured yet. dpkg: error processing package dh-python (--configure): dependency problems - leaving unconfigured dpkg: dependency problems prevent configuration of software-properties-common: software-properties-common depends on python3 (>= 3.2.3-3~); however: Package python3 is not configured yet. software-properties-common depends on python3-gi; however: Package python3-gi is not configured yet. software-properties-common depends on python3-software-properties; however: Package python3-software-properties is not configured yet. dpkg: error processing package software-properties-common (--configure): dependency problems - leaving unconfigured dpkg: dependency problems prevent configuration of python3-apt: python3-apt depends on python3 (= 3.4~); however: Package python3 is not configured yet. dpkg: error processing package python3-apt (--configure): dependency problems - leaving unconfigured dpkg: dependency problems prevent configuration of python3-dbus: python3-dbus depends on python3 (>= 3.3~); however: Package python3 is not configured yet. python3-dbus depends on python3:any (>= 3.3.2-2~); however: Package python3 is not configured yet. python3-dbus depends on python3 ( 

Источник

Error when trying sudo apt-get update - Python related?

I installed Ubuntu 18.04 a few days ago and, while trying to configure it and installing new packaged and software, I think I did something bad. I think it could be related with installing python. Anyway, netiher the gnome-terminal or gnome-tweaks can´t start anymores. Also, when I try to update (sudo apt-get update) it gives me the following error:

sh 1: /usr/lib/cnf-update-db: not found Reading package lists. Done E: Problem executing scripts APT::Update::Post-Invoke-Succes 'if /usr/bin/test -w /var/lib/command-not-found -a -e /usr/lib/cnf-update-db > /dev/null; fi' E: Sub-process returned an error code 

I am relativeley new to Linux so I have no clue how can I fix this. Any idea? Even to restore defult configurations/settings?

If you enter python --version what version do you have default (it should be 2.7.x; it's 2.7.15+ on my 18.10 box) Python (2.7) & Python3 (3.6.6 on my box) are installed by default, and Ubuntu still requires python to run 2.7; you use python3 if you need python 3.x (did you try and make python3 default??). For @valiano's suggestion; the actual error was above your post (dpkg returned code was from calling routine, the subprocess it called reported the error earlier in the output & you only listed the end summary.. I'd re-run sudo apt-get -f install and paste output to your question

3 Answers 3

It is, as suggested by @guiverc, most likely Python version related. It seems that many Python tutorials these days suggests to change the default Python version from 2 to 3. While this is nice and practical for Python development, it breaks the packages which are using Python 2 scripts in there installation process.

So check where the link /usr/bin/python is pointing to:

$ ls -la /usr/bin/python lrwxrwxrwx 1 root root 9 Jan 24 2017 /usr/bin/python -> python2.7 

It should point to python2, not to any python3 executable. If it points to python3 then do the following (man ln):

$ sudo rm -f /usr/bin/python $ sudo ln -s /usr/bin/python2.7 /usr/bin/python 

After that, the apt-get will start to work again.

Background on Python interpreter version

Many scripts use the Shebang to control which interpreter is used to executed the following script. In most Python 2 scripts the following lines are used:

For Python 3 this shebang is used:

If the default link to the Python 2 ( /usr/bin/python -> python2.7 ) interpreter is changed to any version of Python 3, all "old" Python 2 scripts will stop working.

Python version and Ubuntu version

This answer is from 2018. and therefore it applies for Ubuntu 18.04 and probably older versions. For Ubuntu 20.04 the python v2 is more or less deprecated and it must be installed with the meta package sudo apt install python-is-python2 . Also the /usr/bin/python link does not exists if only python v3 is installed.

So it is save to say: This answer is not valid for python3 and Ubuntu versions greater then 18.04.

I ended up re-installing Ubuntu since I had installed a few days ago anyway. But thank you very much for you answer, it totally makes sense what you say about the python pointing. It made me understand the problem and it may help another person.

@russellhoff sure you can change it. and it will break packages that expect python2 linked to /usr/bin/python

In my case this resulted in a slightly different error message: Traceback (most recent call last): File "/usr/lib/cnf-update-db", line 8, in from CommandNotFound.db.creator import DbCreator File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in import apt_pkg ModuleNotFoundError: No module named 'apt_pkg'. I have python 3.9 installed, and what solved it for me was to make python3 point to python3.8 instead of python3.9.

In my case, making python point to python2 just resulted in a slightly different error message:

Traceback (most recent call last): File "/usr/lib/cnf-update-db", line 8, in from CommandNotFound.db.creator import DbCreator File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 11, in import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' 

I have python 3.9 installed, and what solved it for me was to make python3 point to python3.8 instead of python3.9:

$ ls -l /usr/bin/python* lrwxrwxrwx 1 root root 16 Dec 22 13:53 /usr/bin/python -> /usr/bin/python2 lrwxrwxrwx 1 root root 18 Dec 22 13:54 /usr/bin/python2 -> /usr/bin/python2.7 -rwxr-xr-x 1 root root 3674216 Mar 8 2021 /usr/bin/python2.7 lrwxrwxrwx 1 root root 18 Dec 22 13:56 /usr/bin/python3 -> /usr/bin/python3.8 -rwxr-xr-x 1 root root 5490488 Nov 26 21:14 /usr/bin/python3.8 lrwxrwxrwx 1 root root 33 Nov 26 21:14 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config -rwxr-xr-x 1 root root 5803968 Nov 23 16:27 /usr/bin/python3.9 

Источник

Оцените статью