Deba
Deba

Reputation: 441

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-fs0wmmw4/mysqlclient/

When I type the following command in Ubuntu 16.04

$ pip install mysqlclient

I get the following error:

`enter code here`Collecting mysqlclient
  Downloading https://files.pythonhosted.org/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz (89kB)
    100% |████████████████████████████████| 92kB 136kB/s 
    Complete output from command python setup.py egg_info:
    /bin/sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-fs0wmmw4/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-fs0wmmw4/mysqlclient/setup_posix.py", line 44, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-install-fs0wmmw4/mysqlclient/setup_posix.py", line 26, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-fs0wmmw4/mysqlclient/

Upvotes: 10

Views: 13803

Answers (4)

questionto42
questionto42

Reputation: 9532

Taking up this valuable comment from the most voted answer,

apt-get install python-mysqldb

solves this.

For instance, in a Dockerfile, it would look like:

RUN apt-get update
RUN apt-get install -y python-pip libmysqlclient-dev python-dev python-mysqldb

Upvotes: 0

Csutkas
Csutkas

Reputation: 189

I have just faced with this problem on Debian 10:

According to github (https://github.com/PyMySQL/mysqlclient) now should use this:

If you are on # Debian / Ubuntu first run:

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

If you are on # Red Hat / CentOS first run:

sudo yum install python3-devel mysql-devel

Then you can install mysqlclient:

pip install mysqlclient

Upvotes: 4

snoba
snoba

Reputation: 173

After some investigations, and trying different solutions, I found out some points as below:

1- Most of the users install the Python from apt-get on Ubuntu 16.04.

2- The version which is exist on the main Ubuntu repository, is 3.5.x. The mysqlclient that you install with pip, has problem with python3s whose version are under the v3.6. So you should install Python3.6.

3- If you are on Windows, you could use a compiled version of mysqlclient as wheel file. You could find some of wheel files, here. Just download the file, and then:

pip install "path-of-wheel-file"

4- If you are using Ubuntu, as described here, install the python3.6 via these commands:

sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6 python3.6-dev libmysqlclient-dev libmysqld-dev unzip

5- You should update setuptools:

python -m pip install --upgrade pip setuptools wheel

for python3.6:

python3.6 -m pip install --upgrade pip setuptools wheel

6- At the last step, you should install mysqlclient from source:

wget https://github.com/PyMySQL/mysqlclient-python/archive/master.zip
unzip master.zip
cd mysqlclient-python-master
python setup.py install

If your are using Django 1.11 LTS version, you should clone an older mysqlclient version (ex: v1.3.13):

wget https://github.com/PyMySQL/mysqlclient-python/archive/1.3.13.zip
unzip 1.3.13.zip
cd mysqlclient-python-master
python setup.py install

Upvotes: 1

Priyanka Jain
Priyanka Jain

Reputation: 471

Try these instructions:

https://github.com/PyMySQL/mysqlclient-python

Or if you are using python 3. Go with these commands:

sudo apt-get install libmysqlclient-dev

sudo pip3 install mysqlclient

They both worked in my case.

Hope!! this helps

Upvotes: 20

Related Questions