apt - dpkg python-rpi.gpio 依赖问题

apt - dpkg python-rpi.gpio dependency problems

每次我尝试安装、升级或自动删除时都会发生此错误!

我已经在网上搜索并尝试了一些修复程序,但它们似乎不起作用,我没有 python2.7 安装只有 3 并且无法安装 python2 或任何因为这个。我试过 sudo rm python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb 但文件会继续出现。请问我真的需要一些帮助,因为我的 pi 有一些工作并且不想获得新图像

sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  python-rpi.gpio
The following packages will be upgraded:
  python-rpi.gpio
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
18 not fully installed or removed.
Need to get 0 B/20.7 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Reading changelogs... Done
(Reading database ... 152893 files and directories currently installed.)
Preparing to unpack .../python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb ...
/var/lib/dpkg/info/python-rpi.gpio.prerm: 6: /var/lib/dpkg/info/python-rpi.gpio.prerm: pyclean: Too many levels of symbolic links
dpkg: warning: old python-rpi.gpio package pre-removal script subprocess returned error exit status 2
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: 6: /var/lib/dpkg/tmp.ci/prerm: pyclean: Too many levels of symbolic links
dpkg: error processing archive /var/cache/apt/archives/python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb (--unpack):
 new python-rpi.gpio package pre-removal script subprocess returned error exit status 2
/var/lib/dpkg/info/python-rpi.gpio.postinst: 6: /var/lib/dpkg/info/python-rpi.gpio.postinst: pycompile: Too many levels of symbolic links
dpkg: error while cleaning up:
 installed python-rpi.gpio package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 /var/cache/apt/archives/python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

一些注意事项:我真的不想更换 SD 卡并且部分地失去了我拥有的东西,其次我尝试了 sudo apt-get install -fsudo apt update --fix-missing 当我按照这个 guide sudo dpkg --remove --force-remove --reinstreq 命令显示此错误 dpkg: error: unknown force/refuse option 'remove'

使用以下命令:

sudo dpkg -i --force-overwrite /var/cache/apt/archives//python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb

还是一样的问题,使用:

sudo mv /var/lib/dpkg/info/python-rpi.gpio.* /tmp/
sudo dpkg --remove --force-remove-reinstreq python-rpi.gpio

您的命令 sudo dpkg --remove --force-remove --reinstreq 中的错字无效。正确选项是--force-remove-reinstreq。参见 dpkg --force-help

事实证明,我还有 Python2 和 Python3 二进制文件的剩余部分,但 OS 没有正确地 link 编辑它们,这意味着 Python3 被 link 编辑为 Python2,反之亦然。
为了让它工作,我必须:

  • 卸载 Python2 依赖项
  • 让 link 正常工作
  • wget
  • 重新安装 Python2
  • 验证所有 link 是否正常工作(对于 Raspbian 这意味着):
    • python --version links to Python2
    • python2 --version links 到 Python2
    • python3 --version links 到 Python3