MySQLClient instal error: “raise Exception(”Wrong MySQL configuration: maybe https://bugs.mysql.com/

本文详细描述了在使用pip3安装mysqlclient时遇到的一个常见错误及其解决方案。错误涉及配置问题,导致安装过程失败。通过修改mysql_config文件并设置正确的库链接,问题得以解决。此外,还提供了如何配置环境变量以确保安装成功的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 "<string>", line 1, in <module>

      File "/private/var/folders/wz/n9gx1sqj3475nnqnvz4zzy9m0000gn/T/pip-install-vnx2mp28/mysqlclient/setup.py", line 16, in <module>

        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 <listcomp>

        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就成功啦

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值