web-dev-qa-db-ja.com

Python依存関係を持つパッケージのインストール-「壊れたパッケージを保持しています」

Apt-getを使用していくつかのパッケージをUbuntuにインストールしようとしていますが、いくつかのパッケージで同様のエラーが発生します。 「壊れたパッケージを持っている」というメッセージが表示されるので、pythonパッケージに何か問題があるように見えます。

~$ Sudo apt-get install ranger Reading package lists... Done Building dependency tree        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:  ranger : Depends: python:any (< 2.8)
          Depends: python:any (>= 2.7.5-5~)
          Recommends: python-chardet but it is not going to be installed E: Unable to correct problems, you have held broken packages.

~$  python -V
Python 2.7.13
~$  python3 -V
Python 3.5.2

dpkg --get-selections | grep holdは何も提供しないので、何が開催されているのか見つけることができないようです。上記の出力と同様、ubuntuに付属のpython 2と私がインストールしたpython 3の両方がありますが、それでもエラーが発生します。これは私がPythonを不適切にインストールしたという症状ですか、これに対する別の修正がありますか?

2

問題は、ディストリビューションが提供するよりも新しいバージョンにPythonを手動でインストールしたことだったようです。 apt-getがインストールを修復しようとする場合、ダウングレードする必要がありますが、ダウングレードする必要があると指定した場合にのみ可能です。

含むファイル/etc/apt/preferences.d/allow-downgradeの作成

Package: *
Pin: release o=Ubuntu
Pin-Priority: 1001

そして、実行中

apt-get update
apt-get upgrade
apt-get -f install
apt-get update

問題を解決しました。

ソースと詳細な回答:

https://unix.stackexchange.com/questions/218911/help-me-repair-my-python-i-think-dpkg-has-to-be-reset-very-tricky-issue

2