skip to Main Content

I’m getting the following error message while running my Django REST project with MySQL database in pipenv.

raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.
Did you install mysqlclient?

This seems like a very common problem (please don’t mark as duplication), but after trying all the possible solutions I’m still getting the same issue..

A few things I tried:

pip3 install mysqlclient
pip3 install python3.6-dev 
pip3 install mysql-client
pip3 install libsqlclient-dev
pip3 install libssl-dev

What could still be the problem?

It’s a Linux Ubuntu 18.04 server with Plesk. Python version 3.8.

3

Answers


  1. Chosen as BEST ANSWER

    I had to install this.

    sudo apt install libpython3.8-dev
    

    Now it works.


  2. You should install libmysqlclient-dev: sudo apt-get install libmysqlclient-dev

    Login or Signup to reply.
  3. mysqlclient has a dependency on the mysql client & dev packages being installed. In order to fix this on ubuntu, you have to use apt-get to install a couple of mysql packages.

    In your case, it looks like the missing mysql_config might be missing on your system. You can fix that by installing libmysqlclient-dev on ubuntu bionic.

    another way

    install the follwing packages.

    sudo apt-get install python3.8-dev 
    sudo apt-get install mysql-client
    sudo apt-get install libsqlclient-dev
    sudo apt-get install libssl-dev
    

    other method

    pip install pymysql
    

    Then, edit the init.py file in your project origin dir(the same as settings.py)

    add:

    import pymysql
    
    pymysql.install_as_MySQLdb()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search