pip3 install mysql时出现下面问题:
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.6/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/wz/n9gx1sqj3475nnqnvz4zzy9m0000gn/T/pip-install-vnx2mp28/mysqlclient/setup.py'"'"'; __file__='"'"'/private/var/folders/wz/n9gx1sqj3475nnqnvz4zzy9m0000gn/T/pip-install-vnx2mp28/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 pip-egg-info
cwd: /private/var/folders/wz/n9gx1sqj3475nnqnvz4zzy9m0000gn/T/pip-install-vnx2mp28/mysqlclient/
Complete output (11 lines):
Traceback (most recent call last):
File "
File "/private/var/folders/wz/n9gx1sqj3475nnqnvz4zzy9m0000gn/T/pip-install-vnx2mp28/mysqlclient/setup.py", line 16, in
metadata, options = get_config()
File "/private/var/folders/wz/n9gx1sqj3475nnqnvz4zzy9m0000gn/T/pip-install-vnx2mp28/mysqlclient/setup_posix.py", line 63, in get_config
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/wz/n9gx1sqj3475nnqnvz4zzy9m0000gn/T/pip-install-vnx2mp28/mysqlclient/setup_posix.py", line 63, in
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
File "/private/var/folders/wz/n9gx1sqj3475nnqnvz4zzy9m0000gn/T/pip-install-vnx2mp28/mysqlclient/setup_posix.py", line 12, in dequote
raise Exception("Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?")
Exception: Wrong MySQL configuration: maybe https://bugs.mysql.com/bug.php?id=86971 ?
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output
解决方案:
# 修改前先备份
cp mysql_config mysql_config_backup
# 修改编辑权限
chmod 777 mysql_config
vi mysql_config
# 修改114行
> # Create options
> libs="-L$pkglibdir"
> libs="$libs -l "
# 修改为
> # Create options
> libs="-L$pkglibdir"
> libs="$libs -lmysqlclient -lssl -lcrypto"
然后:
新建:touch ~/.bash_profile
open ~/.bash_profile打开文件之后把下面贴在该文件末尾:
export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
然后保存,保存之后source ~/.bash_profile
然后再安装 pip3 install mysqlclient就成功啦