python3下安装mysqlclient各种报错 raise OSError mysql_config not found
在服务器执行
pip install mysqlclient-2.0.1.tar.gz```
报错
Processing ./mysqlclient-2.0.1.tar.gz Complete output from command python setup.py egg_info: /bin/sh: mysql_config: command not found /bin/sh: mariadb_config: command not found /bin/sh: mysql_config: command not found Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-8svitbbv-build/setup.py", line 15, in <module> metadata, options = get_config() File "/tmp/pip-8svitbbv-build/setup_posix.py", line 65, in get_config libs = mysql_config("libs") File "/tmp/pip-8svitbbv-build/setup_posix.py", line 31, in mysql_config raise OSError("{} not found".format(_mysql_config_path)) OSError: mysql_config not found 执行如下
```bash
yum install mysql-devel gcc gcc-devel python-devel```
又报错:
MySQLdb/_mysql.c:46:20: fatal error: Python.h: No such file or directory #include "Python.h" ^ compilation terminated. error: command 'gcc' failed with exit status 1
还是官网最靠谱,可能以上都不用装
```bash
$ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential # Debian / Ubuntu
% sudo yum install python3-devel mysql-devel # Red Hat / CentOS```
在服务器执行
```bash
pip install mysqlclient-2.0.1.tar.gz```
Processing ./mysqlclient-2.0.1.tar.gz Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... done Successfully installed mysqlclient-2.0.1