Problems with apt dependencies after install of python 3.5
Solution 1
Thank goodness I was able to fix it. I was worried I was gonna have to reinstall ubuntu.
I went and manually edited /var/lib/dpkg/status
and removed the entry that was made by the checkinstall
.
Once that was removed I went to /usr/local/bin
and removed all the python 3.5 stuff. I also made sure that python3-4 was still in /usr/bin/
. Then I did a sudo dpkg-reconfigure -a
and finally a apt-get -f install
and there was only 1 thing that was 'missing' which was python.
Then I managed to get it installed the right way by following the instructions in the README and then just removing the symlink to python3.4 and created a new one to python3.5.
Solution 2
I had the same problem after installing python3.4 with checkinstall
(instead of python3.5 for electrometro
)
Reason why this problem occurs
I discovered why this problem did occurred on the first place.
When creating the .deb file from the Python 3.4 source with checkinstall
that then installs it, the default package-name set up by checkinstall is "python".
As a consequence, checkinstall
uninstall the package named python before installing the new one using dpkg
!! This package already exists in Ubuntu. It is basically linked to python2! For some reason hopefully, I think that dpkg
tries to remove the version of python that you are installing, i.e python3.4 in my case but fails. That is why python2 is still installed. But dpkg
still believe "python" package was removed and replaced by the new one installed (python3.4).
The file /var/lib/dpkg/status has been edited accordingly. In my case here is the updated related to this installation:
Package: python
Status: deinstall ok installed
Priority: extra
Section: checkinstall
Installed-Size: 167520
Maintainer: root@laptop
Architecture: amd64
Version: 3.4.3-1
Provides: python
Description: Package created with checkinstall 1.6.2`
As you can see in bold, the Package name is "python" and the package has been "deinstall" before being installed again.
Thus, dpkg
thinks that "python" (python2!) no longer exists and suggest you to remove everything that is dependent to it when you call apt-get -f install
!
Solution to avoid this problem:
Simply choose a different "Package" name and "Provides" name when using checkinstall! For example python3.4-checkinstall for both.
How to solve the problem when it already occured
To solve this mess, I have a solution that enable you not to have to remove all installed binaries manually as electrometro
suggested to do, which I think might be dangerous.
Follow these steps:
- Manually edit the Package name
python
in/var/lib/dpkg/status
frompython
topython-3.4-checkinstall
for example. Be careful. The new name must not have been used already! Also change "Provides" to the new name. - Use
sudo dpkg-reconfigure python-3.4-checkinstall
. (Note:dpkg-reconfigure -a
as suggestedelectrometro
does not exist anymore in Ubuntu 16.04. It is anyway not needed). - Run
apt-get -f install
that will install the originalpython
package again! At this point you can stop here but if you trysudo dpkg-query -L python3.4-checkinstall
: dpkg does not know which files have been installed anymore!!! Because the file /var/lib/dpkg/info/python3.4-checkinstall.list does not exist! The file /var/lib/dpkg/info/python.list have been overriden byapt-get -f install
. See the Debian documentation for more info ondpkg
. To solve this issue, you must do the step 4. - Reinstall python3.4 from scratch using checkinstall but without forgetting to change the "Package" name and the "Provides" name as suggested earlier! Use the same name as in step 1. No need to delete the binaries manually before doing so. The point of this step is to have a clean installation of python3.4 and be able to uninstall it using the newly created .deb file.
And that's it! Everything should be clean now. I actually ran step 3 before step 2 but it should be cleaner to do it this way.
For info the step I used to install python3.4 from the source package using checkinstall are the folowing:
- In the source directory, run
./configure
. - Run
make
- Run
sudo checkinstall
- Most important step. At this point they ask you if you want to modify any field before installing. Modify "Package" and "Provides" from "python" to a different unique name (like "python3.4-checkinstall" as I suggested).
Hope it helps!
Cheers, Nicolas
Related videos on Youtube
Jared Mackey
Updated on September 18, 2022Comments
-
Jared Mackey over 1 year
I downloaded and compiled the latest python, 3.5, and installed it with checkinstall. Now I am getting a ton of packages that have missing dependencies in apt.
apt-xapian-index : Depends: python (< 2.8) but 3.5.0-1 is to be installed duplicity : Depends: python (< 2.8) but 3.5.0-1 is to be installed gconf2 : Depends: python:any . . . totem-plugins : Depends: python:any (>= 2.6.6-7~) ubuntu-system-service : Depends: python (< 2.8) but 3.5.0-1 is to be installed Depends: python:any (>= 2.7.1-0ubuntu2) E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
But I still have python installed including 2.7.9.
$ which python /usr/bin/python $ python Python 2.7.9 (default, Apr 2 2015, 15:33:21) [GCC 4.9.2] on linux2 $ which python3 /usr/local/bin/python3 $ python3 Python 3.5.0 (default, Sep 13 2015, 19:47:21) [GCC 4.9.2] on linux
How do I either remove the package I installed or fix the dependencies not seeing that python3 is installed?
Also, python3.4 is still at
/usr/bin/python3
EDIT: I see that it wants me to do
apt-get -f install
but it is removing a ton of stuff and I really don't think that is the right way to fix it. -
andyhasit over 7 yearsCould you please elaborate on what entry you removed? I have the same issue and am totally at a lose end!
-
Jared Mackey over 7 years@andyhasit It's been awhile but I believe it was a python 3.5 entry.
-
andyhasit over 7 years@electrometro Ok, I read I could safely empty that file (having made a backup) but now dpkg-reconfigure doesn't like flag -a. I'll investigate!