Python Forum

Full Version: Pip install for mysqlclient not working
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to install the mysqlclient with Pip, and get an error as follows.

$ pip3.4 install mysqlclient
Downloading/unpacking mysqlclient
  Downloading mysqlclient-1.3.12.tar.gz (89kB): 89kB downloaded
  Running setup.py (path:/tmp/pip_build_root/mysqlclient/setup.py) egg_info for package mysqlclient
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/tmp/pip_build_root/mysqlclient/setup_posix.py", line 44, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip_build_root/mysqlclient/setup_posix.py", line 26, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: command not found

Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/mysqlclient/setup.py", line 17, in <module>

    metadata, options = get_config()

  File "/tmp/pip_build_root/mysqlclient/setup_posix.py", line 44, in get_config

    libs = mysql_config("libs_r")

  File "/tmp/pip_build_root/mysqlclient/setup_posix.py", line 26, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

OSError: mysql_config not found

----------------------------------------
Cleaning up...
From what I could tell, this means it's missing a library, so I downloaded and installed the RPMs for the Python and C++ libraries from Oracle's site. These are the mysql RPMs installed on the system:

$ rpm -qa | grep -i mysql
mysql-connector-python-2.1.7-1.el6.x86_64
MySQL-server-advanced-5.6.30-1.el6.x86_64
mysql-connector-c++-1.1.9-1.x86_64
MySQL-client-advanced-5.6.30-1.el6.x86_64
MySQL-python-1.2.3-0.3.c1.1.el6.x86_64
MySQL-shared-compat-advanced-5.6.22-1.el6.x86_64 
Yet, it seems that mysql_config still not installed, and so is not found:

$ locate mysql_config
/usr/bin/mysql_config_editor
/usr/share/man/man1/mysql_config_editor.1.gz
Note that some sites say to install libmysqlclient-dev, which I think would apply if I'm installing the RPMs from Redhat. But my departmental standard is to use the ones supplied by Oracle, which are the ones that appear above.

These are my versions:

$ pip3.4 -V
pip 1.5.6 from /usr/local/lib/python3.4/site-packages (python 3.4)
$ python3.4 -V
Python 3.4.2
Anybody know which RPM I need to install?
if your on ubuntu
sudo apt-get install libmysqlclient-dev python-dev
Notice you have not a shell command called "mysql_config"

Using yum
Quote:yum provides mysql_config

In my case, I should install mariadb-devel
Quote:yum install mariadb-devel

If you get gcc error, please check this post
https://stackoverflow.com/questions/3632...centos-7-2

Hope this help!
This error may pop up due to lack of dependencies and libraries. Follow these steps before pip install mysqlclient.
For Debian / Ubuntu
Quote:sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
sudo apt-get install zlib1g-dev
If this didn't worked try checking this Solution for Django MySQLClient pip compile failure on Linux Arrow Heart
In general, if you're compiling something, you're going to want the -dev packages. The runtime libraries are normally not enough to compile something with. This applies pretty much across the board with linux, and is not related to python.