我在Kubuntu19.10上,我从源代码中构建了python3.8,并使用checkinstall安装了它。然后我删除了它,它以某种方式破坏了python2.7。如果我尝试安装任何python-*包,它会产生一个类似于此的错误:
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:
python-dev : Depends: python (= 2.7.17-1) but 3.8.1-1 is to be installed
E: Unable to correct problems, you have held broken packages.我试过sudo dpkg --configure -a,但没什么用。
我该怎么解决这个问题?
编辑:apt-cache policy python输出:
python:
Installed: 3.8.1-1
Candidate: 3.8.1-1
Version table:
*** 3.8.1-1 100
100 /var/lib/dpkg/status
2.7.17-1 500
500 http://si.archive.ubuntu.com/ubuntu eoan/universe amd64 Packages发布于 2020-02-24 13:20:14
Python3.8.1是以Python的名字安装的,所以我所做的就是运行sudo dpkg -r python并解决它。
发布于 2020-02-24 13:10:48
试着跑
ls -lh /usr/bin/python查看默认python版本是否为2.7。如果没有,请查看是否安装了python2.7可执行文件
ls /usr/bin/python*使您的/usr/bin/python链接指向正确的python版本
rm /usr/bin/python
ln -s /usr/bin/python2.7 python当然,确保在/usr/bin/中有指向python2.7配置文件的链接。例如,我有/usr/bin/python2-config指向python2.7-config
发布于 2020-02-24 13:29:09
当您构建包时,看起来它是'python‘而不是’python 3.8‘。
那是不明智的。现在,系统期望'python‘为3.8版,而不是2.7版。
如果您有很多不想重新安装的Python2包,如何修复它:
1)对所有数据进行完整备份,并手头上有一个工作的LiveUSB。你要用很强的药。病人可能有意想不到的并发症。
2)确保删除构建的Python3.8包的所有跟踪。
3)删除python包安装的所有文件,同时保留Python2.7包的其余部分。
sudo dpkg remove python --force-depends
// 'python' places no files in /etc, so 'remove' is appropriate.4)从apt/dpkg数据库中删除python包的所有跟踪。警告:如果使用不当,此命令可能破坏您的系统。
sudo dpkg remove python --force-depends --force-remove-reinstreq5)重新安装正确的python包:
sudo apt install pythonhttps://askubuntu.com/questions/1212690
复制相似问题