web-dev-qa-db-ja.com

Pythonのため、パッケージをインストールできません

愚かなPythonパッケージのため、Raspbian(Debian)にapt-getのパッケージをインストールできません。

Sudo dpkg --configure -aしようとしましたが、それでもこれらのエラーが発生します。

メッセージ:

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 <module>
    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 <module>
    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.5); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-gi (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of unattended-upgrades:
 unattended-upgrades depends on python3; however:
  Package python3 is not configured yet.

dpkg: error processing package unattended-upgrades (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-software-properties:
 python3-software-properties 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.5); however:
  Package python3 is not configured yet.
 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 (<< 3.5); however:
  Package python3 is not configured yet.

dpkg: error processing package python3-dbus (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-software-properties:
 python-software-properties depends on unattended-upgrades; however:
  Package unattended-upgrades is not configured yet.

dpkg: error processing package python-software-properties (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python3
 python3-gi
 unattended-upgrades
 python3-software-properties
 dh-python
 software-properties-common
 python3-apt
 python3-dbus
 python-software-properties
2
user813320

python 2.7に戻る

次のコマンドを使用します:

Sudo update-alternatives --config python

エラーが発生した場合:

update-alternatives: error: no alternatives for python

次のようにupdate-alternativesを更新します。

ls /usr/bin | grep python | columns

サンプル出力:

dh_python2  idle-python3.4  python2     python3     python3.4m
dh_python3  python      python2.7   python3.4   python3m

python2.7python3.4があり、次を実行します。

Sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
Sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2

update-alternatives --helpをご覧ください

これで実行できます。

Sudo update-alternatives --config python

サンプル出力:

There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.4   2         auto mode
  1            /usr/bin/python2.7   1         manual mode
  2            /usr/bin/python3.4   2         manual mode

Press enter to keep the current choice[*], or type selection number: 1

python2.7をデフォルトとして設定するには、1を選択します

実行:

Sudo dpkg --configure -a
Sudo apt update

コマンドhistoryを使用して、システムを破壊する最新のインストール済み*-pythonパッケージを取得し(たとえば、python-scapy)、それを削除します。

Sudo apt-get remove python-scapy

完了したら、python3.4コマンドを使用してupdate-alternativeに戻すことができます。

3
GAD3R