遇到/bin/sh: mysql_config: command not found的问题
在执行 pip install pytest-mysql的时候出现以下错误:
/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 pytest-mysql
成功。
Ubuntu系统解决方案
pip3 install mysqlclient
报错 “/bin/sh: 1: mysql_config: not found”的解决方法
执行
sudo apt-get install libmysqlclient-dev
pip3 install pytest-mysql
成功。