我正在尝试在 Ubuntu 20.04 中为 Python 2.7 安装 python-mysqldb:
$ sudo add-apt-repository 'deb http://archive.ubuntu.com/ubuntu bionic main'
$ sudo apt update
$ sudo apt install -y python-mysqldb
我收到以下错误:
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-mysqldb : Depends: python (< 2.8)
Depends: python (>= 2.7~)
Depends: python:any (< 2.8)
Depends: python:any (>= 2.7.5-5~)
E: Unable to correct problems, you have held broken packages.
知道如何修复它吗?
我在 Ubuntu 20.04 中安装了 Python 2.7.18 和 Python 3
答案1
您必须通过以下方式撤消存储库添加
sudo add-apt-repository -r 'deb http://archive.ubuntu.com/ubuntu bionic main'
然后下载两个包裹来自 18.04 LTS 存储库并使用以下命令安装它们:
sudo apt-get update
cd ~/Downloads
wget -c http://archive.ubuntu.com/ubuntu/pool/main/p/python-mysqldb/python-mysqldb_1.3.10-1build1_amd64.deb
wget -c http://security.ubuntu.com/ubuntu/pool/main/m/mysql-5.7/libmysqlclient20_5.7.36-0ubuntu0.18.04.1_amd64.deb
sudo apt-get install ./python-mysqldb_1.3.10-1build1_amd64.deb ./libmysqlclient20_5.7.36-0ubuntu0.18.04.1_amd64.deb