由于 Python 无法安装任何包

2 python apt-get raspbian

apt-get由于愚蠢的 Python 软件包,我无法在 Raspbian (Debian) 上安装任何软件包。

\n\n

我尝试sudo dpkg --configure -a\n但即使这样我\xe2\x80\x99m 也收到这些错误!

\n\n

留言:

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

GAD*_*D3R 5

切换回 python 2.7

使用命令:

sudo update-alternatives --config python
Run Code Online (Sandbox Code Playgroud)

如果出现错误:

update-alternatives: error: no alternatives for python
Run Code Online (Sandbox Code Playgroud)

更新您的update-alternatives如下:

ls /usr/bin | grep python | columns
Run Code Online (Sandbox Code Playgroud)

示例输出:

dh_python2  idle-python3.4  python2     python3     python3.4m
dh_python3  python      python2.7   python3.4   python3m
Run Code Online (Sandbox Code Playgroud)

你有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
Run Code Online (Sandbox Code Playgroud)

update-alternatives --help

现在你可以跑了;

sudo update-alternatives --config python
Run Code Online (Sandbox Code Playgroud)

示例输出:

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
Run Code Online (Sandbox Code Playgroud)

要将其设置python2.7为默认值,请选择 1

跑步 :

sudo dpkg --configure -a
sudo apt update
Run Code Online (Sandbox Code Playgroud)

使用该命令history获取最新安装的*-python软件包,该软件包会破坏您的系统(例如;python-scapy),然后将其删除:

sudo apt-get remove python-scapy
Run Code Online (Sandbox Code Playgroud)

完成后,您可以恢复python3.4使用该update-alternative命令