在mac中pip安装mysqlclient时出错[重复]
Posted
技术标签:
【中文标题】在mac中pip安装mysqlclient时出错[重复]【英文标题】:error when pip install mysqlclient in mac [duplicate] 【发布时间】:2020-03-12 17:35:38 【问题描述】:当我尝试 pip install mysqlclient for python 时显示此错误
ERROR: Command errored out with exit status 1:
command: /Users/als/Desktop/Projects/sin/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/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 /private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/pip-egg-info
cwd: /private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/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 "/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/private/var/folders/30/y2trygfx15x0v9h9v8dt9dsc0000gn/T/pip-install-s44a4z2o/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
错误:命令出错,退出状态为 1:python setup.py egg_info 检查日志以获取完整的命令输出。
【问题讨论】:
嗨,你找到解决方案了吗? 【参考方案1】:解决这个问题只需要两步:
brew install mysql
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
【讨论】:
以上是关于在mac中pip安装mysqlclient时出错[重复]的主要内容,如果未能解决你的问题,请参考以下文章
在 Ubuntu 18.04 上为 python 安装 mysqlclient 时出错
mac设置python及pip环境变量及安装mysqlclient