在debian9上用django搭建后台用到mysql数据库,提示报错信息如下:

Collecting mysqlclient
Downloading http://mirrors.aliyun.com/pypi/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz (90kB)
100% |████████████████████████████████| 92kB 1.8MB/s
Complete output from command python setup.py egg_info:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-60aHlQ/mysqlclient/setup.py", line 18, in <module>
metadata, options = get_config()
File "setup_posix.py", line 53, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 28, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-60aHlQ/mysqlclient/

 

网上的好多解决方案是说通过apt-get install python3-dev libmysqlclient-dev解决,但libmysqlclient-dev早已过时,现在用libmariadbclient-dev代替了,所以要执行下面命令安装:

apt-get install python3-dev libmariadbclient-dev

之后安装mysqlclient

pip install mysqlclient