Unable to install mysqlclient on Ubuntu 22.04.3

I want to install MySQL on my Ubuntu 22.04.3 for a Django course I’m taking. I used the following command:

pip install mysqlclient

I tried the suggestions in this thread: Unable to install mysqlclient on Ubuntu 20.10

I followed the steps mentioned but didn’t resolve it.

Step 1 wasn’t working because libssl1.1 is deprecated so I installed libssl3.

Step 2 does not work even if I use:

sudo apt install libssl3=1.1.1f-1ubuntu2

instead of:

sudo apt install libssl1.1=1.1.1f-1ubuntu2

I guess is not the right way.

Then I successfully installed the following:

sudo apt install libssl-dev
sudo apt install libmysqlclient-dev

But even after this I keep getting error when running pip install mysqlclient:

enter image description here

Will appreciate some help or guidance to resolve this.

Asked By: JP Montufar


The error /bin/sh: 1: pkg-config: not found is telling you, that pkg-config is missing.

To install pkg-config package, run this command:

sudo apt install pkg-config
Answered By: sotirov
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.