问题描述
每次我尝试安装某些东西时,升级或自动删除都会发生此错误!
我在网上搜索并尝试了一些修复,但它们似乎不起作用,我没有安装 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 -f
和 sudo apt update --fix-missing
,当我跟着这个 {{3} } sudo dpkg --remove --force-remove --reinstreq
命令显示此错误 dpkg: error: unknown force/refuse option 'remove'
解决方法
事实证明,我仍然有 Python2 和 Python3 二进制文件的剩余部分,并且它们没有被操作系统正确链接,这意味着 Python3 已链接到 Python2,反之亦然。
为了让它工作,我必须:
- 卸载 Python2 依赖项
- 使链接正常工作
- 使用
wget
重新安装 Python2 - 验证所有链接是否正常工作(对于 Raspbian 这意味着):
- python --version 链接到 Python2
- python2 --version 链接到 Python2
- python3 --version 链接到 Python3
使用以下命令:
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
。