Install python-mysqldb for Python 2.7 in Ubuntu 20.04 - unmet dependencies
I am trying to install python-mysqldb for Python 2.7 in Ubuntu 20.04:
$ sudo add-apt-repository 'deb bionic main'
$ sudo apt update
$ sudo apt install -y python-mysqldbI get the following error:
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.Any idea how I can fix it?
I have Python 2.7.18 and Python 3 installed in my Ubuntu 20.04
1 Answer
You have to undo repository addition by
sudo add-apt-repository -r 'deb bionic main'and then download two packages from 18.04 LTS repository and install them by using commands below:
sudo apt-get update
cd ~/Downloads
wget -c
wget -c
sudo apt-get install ./python-mysqldb_1.3.10-1build1_amd64.deb ./libmysqlclient20_5.7.36-0ubuntu0.18.04.1_amd64.deb