我想在django中使用mysql所以,尝试使用$ pip3 install mysqlclient
下载mysqlclent,但总是会出现此错误
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/
这是我的终端日志
$ pip3 install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-1.3.9.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "/private/var/folders/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "/private/var/folders/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/setup_posix.py", line 26, 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/hb/vmtpfjk12fdcm_8l95hfqzmr0000gn/T/pip-build-pm_wn_w8/mysqlclient/
请帮忙
答案 0 :(得分:3)
$ pip3 install mysqlclient
表示您打算使用Python3安装该软件包。根据描述中的错误,我相信您的机器可能缺少MySQL。根据{{3}},MySQLConnectorC是在OSX上运行mysqlclient的先决条件之一。
brew install mysql-connector-c
应解决您的问题。
答案 1 :(得分:0)
尝试将MySQL添加到您的路径:
export PATH=${PATH}:/usr/local/mysql/bin/