Linux上使用pip 安装mysqlclient,pip install mysqlclient==2.0.1遇到的问题:OSError: mysql_config not found

Posted 为何一再沦落

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux上使用pip 安装mysqlclient,pip install mysqlclient==2.0.1遇到的问题:OSError: mysql_config not found相关的知识,希望对你有一定的参考价值。


exit status 1:
command: /usr/local/python3/bin/python3.8 -c import sys, setuptools, tokenize; sys.argv[0] = ""/tmp/pip-install-n39j9wjd/mysqlclient/setup.py""; __file__=""/tmp/pip-install-n39j9wjd/mysqlclient/setup.py"";f=getattr(tokenize, ""open"", open)(__file__);code=f.read().replace(""\\r\\n"", ""\\n"");f.close();exec(compile(code, __file__, ""exec"")) egg_info --egg-base /tmp/pip-pip-egg-info-e9wzw22i
cwd: /tmp/pip-install-n39j9wjd/mysqlclient/
Complete output (12 lines):
/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-install-n39j9wjd/mysqlclient/setup.py", line 15, in <module>
metadata, options = get_config()
File "/tmp/pip-install-n39j9wjd/mysqlclient/setup_posix.py", line 65, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-n39j9wjd/mysqlclient/setup_posix.py", line 31, in mysql_config
raise OSError(" not found".format(_mysql_config_path))
OSError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command

解决方法:安装mysql-devel

centos系统使用yum安装 mysql-devel

yum install mysql-devel

ubuntu 系统apt-get 安装libmysqlclient-dev

apt-get update
apt-get upgrade
apt-get install libmysqlclient-dev

debian 系统

apt install -y libmariadbd18
apt install

之后可能还会安装失败,目前看来可能是版本太低的原因,直接安装默认的版本可以成功。

pip install


以上是关于Linux上使用pip 安装mysqlclient,pip install mysqlclient==2.0.1遇到的问题:OSError: mysql_config not found的主要内容,如果未能解决你的问题,请参考以下文章

使用pip install mysqlclient命令安装mysqlclient失败?(基于Python)

使用 pip 安装 mysqlclient 时如何解决此问题

pip install mysqlclient 安装失败

MacOS下安装使用pip方式安装mysqlclient

无法 pip3 安装 mysqlclient

如何在python中安装mysqlclient?