遇到/bin/sh: mysql_config: command not found的问题

在执行 pip install mysqlclient的时候出现以下错误:
/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found

/bin/sh: mysql_config: command not found
/bin/sh: mariadb_config: command not found
/bin/sh: mysql_config: command not found

macOS解决方案

执行

 brew install mysql-client 

根据打印信息添加到对应的文件

If you need to have mysql-client first in your PATH, run:
  echo 'export PATH="/usr/local/opt/mysql-client/bin:$PATH"' >> ~/.zshrc

For compilers to find mysql-client you may need to set:
  export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
  export CPPFLAGS="-I/usr/local/opt/mysql-client/include"

For pkg-config to find mysql-client you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/mysql-client/lib/pkgconfig"

这里提示是./zshrc文件

#mysql-client
export PATH="/usr/local/opt/mysql-client/bin:$PATH"
#mysql-client compilers
export LDFLAGS="-L/usr/local/opt/mysql-client/lib"
export CPPFLAGS="-I/usr/local/opt/mysql-client/include"
#mysql-client pkg-config
export PKG_CONFIG_PATH="/usr/local/opt/mysql-client/lib/pkgconfig"

然后执行

pip3 install mysqlclient

成功。

Ubuntu系统解决方案

pip3 install mysqlclient 报错 “/bin/sh: 1: mysql_config: not found”的解决方法

执行

sudo apt-get install libmysqlclient-dev

然后执行

pip3 install mysqlclient

成功。

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐