Unable to install mysqlclient on Ubuntu 20.10

10,399

Solution 1

Check this thread, maybe it helps you.

Error installing libmysqlclient-dev on Ubuntu 20.04

Step 0: sudo apt install python3-dev build-essential

Step 1: sudo apt install libssl1.1

Step 2: sudo apt install libssl1.1=1.1.1f-1ubuntu2

Step 3: sudo apt install libssl-dev

Step 4: sudo apt install libmysqlclient-dev

Step 5: pip3 install mysqlclient

That's it!

ps: To find out these all steps, I was spent almost 4-5 Hours. :D

Solution 2

As mentioned here you should do:

  • sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
    Debian / Ubuntu
  • sudo yum install python3-devel mysql-devel
    Red Hat / CentOS

After that just do pip install mysqlclient

Solution 3

This can usually be resolved with the libffi-dev libraries; libffi.so specifically. It can be installed via apt with:

sudo apt install libffi-dev

Note: I have not found a way to install this via pip3. Do let me know if you find it somewhere.

Once libffi-dev is installed, run ldconfig to load the new .so.

Important: If you compiled your own Python installation, then you will need to recompile it for libffi-dev to be loaded.

Share:
10,399

Related videos on Youtube

Shivangi Varshney
Author by

Shivangi Varshney

Updated on September 18, 2022

Comments

  • Shivangi Varshney
    Shivangi Varshney over 1 year

    I want to install MySQL on my Ubuntu 20.10 desktop, but I'm facing issues. I tried installing python3-dev and libmysqlclient-dev.

    When running:

    pip3 install mysqlclient
    

    I keep getting the error below:

    pip3 install mysqlclient error

    How may I solve this?

    • Shivangi Varshney
      Shivangi Varshney about 3 years
      @BeastofCarerbannog I did install libffi-dev and executed ldconfig. Still getting the same error. While doing pip install mysqlclient. The error is still the same.
  • Mai Hai
    Mai Hai over 2 years
    It works for Ubuntu 18.04 too.
  • FisNaN
    FisNaN about 2 years
    I have venv set to Python 3.9. In my case, I use sudo apt install python3.9-dev. Anything else is the same. and it works!