Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ubuntu 17: Can't install mysqlclient

Trying to follow a Django tutorial but I cannot install mysqlclient.

The tutorial claims that I can do so with the following command:

pip install mysqlclient

but this generates this error:

Collecting mysqlclient   Using cached mysqlclient-1.3.12.tar.gz
    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-build-rrolctwh/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/tmp/pip-build-rrolctwh/mysqlclient/setup_posix.py", line 44, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-build-rrolctwh/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-build-rrolctwh/mysqlclient/

I have the most up-to-date pip and virtualenv installed.

I would like to be able to install mysqlclient so that I may continue with the tutorial.

like image 944
Matt Avatar asked Jan 29 '23 04:01

Matt


2 Answers

You should also install the mysql and python development headers and libraries: https://github.com/PyMySQL/mysqlclient-python#prerequisites

like image 169
Arjen Dijkstra Avatar answered Jan 31 '23 20:01

Arjen Dijkstra


I was facing the same problems, but following the instructions in the Official mysqlclient documentation fixed it for me

but just to clarify I was running python 3.5 from a virtual environment and after installing the prerequisites, it all worked fine

like image 27
maroof shittu Avatar answered Jan 31 '23 18:01

maroof shittu