ubuntu安装mysqlclient错误解决
mysqlclient is a python library that you need to connect to a MySQL database using MySQLdb. However, when you install mysqlclient on ubuntu 16.04 LTS, you may get the following error:
$ pip install mysqlclient
Collecting mysqlclient Using cached mysqlclient-1.3.10.tar.gz Complete output fromcommand python setup.py egg_info: /bin/sh: 1: mysql_config: not found Traceback(most recent call last): File"", line 1,in File"/tmp/pip-build-58kk7s2k/mysqlclient/setup.py", line 17,in metadata, options=get_config()File"/tmp/pip-build-58kk7s2k/mysqlclient/setup_posix.py", line 44,in get_config libs=mysql_config("libs_r")File"/tmp/pip-build-58kk7s2k/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 1in/tmp/pip-build-58kk7s2k/mysqlclient/
So, the message says that mysql_config is not found.
At first glance, I thought that this must be some kind of a configuration file. However, it is actually a program for a Unix-based OS’s that you need to connect to a MySQL db. (See here for more details.)
The mysql_config program is provided in the central repository, so you can easily get mysql_config by executing
$ sudo apt install libmysqlclient-dev
Now, you can install mysqlclient without any problem.
$ pip install mysqlclient