在家办公于是将工作环境换到了mac,配置环境的时候安装mysqlclient出现了下面的错误:
(venv_home_mini) obaby@Obabys-Mac-mini taichigameserver % pip3 install mysqlclient
Collecting mysqlclient
Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.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 "", line 1, in
File "/private/var/folders/gf/qbbv4crd5m9f1vkz5066dvyw0000gn/T/pip-install-m5gv0sbr/mysqlclient/setup.py", line 16, in
metadata, options = get_config()
File "/private/var/folders/gf/qbbv4crd5m9f1vkz5066dvyw0000gn/T/pip-install-m5gv0sbr/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/private/var/folders/gf/qbbv4crd5m9f1vkz5066dvyw0000gn/T/pip-install-m5gv0sbr/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/gf/qbbv4crd5m9f1vkz5066dvyw0000gn/T/pip-install-m5gv0sbr/mysqlclient/
网上搜了一下说安装mysql-connector-c ,但是安装之后依然报错。于是尝试安装mysql,安装mysql之后解决该问题,其实出问题的地方在于这个命令找不到,如果直接在终端中执行mysql_config如果能够执行成功,那么只需要创建个软连接就可以解决这个问题。
(venv_home_mini) obaby@Obabys-Mac-mini taichigameserver % mysql_config
Usage: /usr/local/bin/mysql_config [OPTIONS]
Compiler: AppleClang 11.0.0.11000033
Options:
--cflags [-I/usr/local/Cellar/mysql/8.0.19/include/mysql ]
--cxxflags [-I/usr/local/Cellar/mysql/8.0.19/include/mysql ]
--include [-I/usr/local/Cellar/mysql/8.0.19/include/mysql]
--libs [-L/usr/local/Cellar/mysql/8.0.19/lib -lmysqlclient -lssl -lcrypto]
--libs_r [-L/usr/local/Cellar/mysql/8.0.19/lib -lmysqlclient -lssl -lcrypto]
--plugindir [/usr/local/Cellar/mysql/8.0.19/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [8.0.19]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/Cellar/mysql/8.0.19/include/mysql]
pkglibdir [/usr/local/Cellar/mysql/8.0.19/lib]
plugindir [/usr/local/Cellar/mysql/8.0.19/lib/plugin]
安装命令:
brew install mysql
如果没有安装homebrew,通过下面的命令安装:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
1 comment
ubuntu系统下可能需要安装libmysqlclient-dev
apt-get install libmysqlclient-dev