[Django]-Error with pip install MySQL-python

12πŸ‘

In my opinions mysql_config is missing on your system or the installer could not find it. Please Be sure mysql_config is really installed.

For instance,

  • On Debian/Ubuntu, You must install the package:
    sudo apt-get install libmysqlclient-dev

  • Running Mac OSX Mountain Lion, I simply ran this in terminal to fix:
    export PATH=$PATH:/usr/local/mysql/bin

This is the quickest fix I found.

πŸ‘€Richard Morin

3πŸ‘

I was also getting the same error while installing the mysql package by pip But after installing libmysqlclient-dev

  • sudo apt install libmysqlclient-dev
  • pip install mysql

Now it worked for me..

verified:

import mysql

  • did not find any error, Means got installed successfully and working
    properly
πŸ‘€JON

1πŸ‘

Check your mysql configuration file using this:

mysql_config

Now you should get an output something like this:

mysql_config 
Usage: /usr/bin/mysql_config [OPTIONS]
Compiler: GNU 6.3.0
Options:
        --cflags         [-I/usr/include/mysql ]
        --cxxflags       [-I/usr/include/mysql ]
        --include        [-I/usr/include/mysql]
        --libs           [-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -ldl]
        --libs_r         [-L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -ldl]
        --plugindir      [/usr/lib/mysql/plugin]
        --socket         [/var/run/mysqld/mysqld.sock]
        --port           [0]
        --version        [5.7.18]
        --libmysqld-libs [-L/usr/lib/x86_64-linux-gnu -lmysqld -lpthread -lz -lm -lrt -latomic -lcrypt -ldl -laio -llz4 -lnuma]
        --variable=VAR   VAR is one of:
                pkgincludedir [/usr/include/mysql]
                pkglibdir     [/usr/lib/x86_64-linux-gnu]
                plugindir     [/usr/lib/mysql/plugin]
Ideally it should contain libmysqld-libs option. If it is not there, as it was not there in my case, you can assume that your mysql is broken.

In this case you can write this configuration to config file directly

1πŸ‘

If you are using Windows OS download and install mysql-python directly from here .

πŸ‘€roy

0πŸ‘

Not sure if it useful. But it help me to solve the problem.

apt-get install build-essential zlib1g zlib1g-dev zlibc libxml2 libxml2-dev
πŸ‘€Danny Hong

0πŸ‘

For completeness sake, on Debian Stretch the pkg is now called default-libmysqlclient-dev.

sudo apt-get install default-libmysqlclient-dev
πŸ‘€orotalt

0πŸ‘

I run the following commands and it worked smooth in Ubuntu 17.10

sudo apt-get install libmysqlclient-dev
pip3 install mysqlclient
πŸ‘€Fthi.a.Abadi

Leave a comment