macos pip install mysqlclient error command ‘ usr bin clang‘ failed with exit code 1

Building wheel for mysqlclient (pyproject.toml) … error
error: subprocess-exited-with-error

× Building wheel for mysqlclient (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [45 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-14-x86_64-cpython-39
creating build/lib.macosx-14-x86_64-cpython-39/MySQLdb
copying MySQLdb/init.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb
copying MySQLdb/compat.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb
creating build/lib.macosx-14-x86_64-cpython-39/MySQLdb/constants
copying MySQLdb/constants/init.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-14-x86_64-cpython-39/MySQLdb/constants
running build_ext
building ‘MySQLdb._mysql’ extension
creating build/temp.macosx-14-x86_64-cpython-39
creating build/temp.macosx-14-x86_64-cpython-39/MySQLdb
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/openssl@1.1/include -Dversion_info=(1,4,4,‘final’,0) -D__version__=1.4.4 -I/usr/local/Cellar/mysql/8.3.0_1/include/mysql -I/Users/skyler/Documents/py-env/include -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.macosx-14-x86_64-cpython-39/MySQLdb/_mysql.o
MySQLdb/_mysql.c:489:9: error: call to undeclared function ‘mysql_ssl_set’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
mysql_ssl_set(&(self->connection), key, cert, ca, capath, cipher);
^
MySQLdb/_mysql.c:489:9: note: did you mean ‘mysql_close’?
/usr/local/Cellar/mysql/8.3.0_1/include/mysql/mysql.h:797:14: note: ‘mysql_close’ declared here
void STDCALL mysql_close(MYSQL *sock);
^
MySQLdb/_mysql.c:1650:9: error: call to undeclared function ‘mysql_kill’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
r = mysql_kill(&(self->connection), pid);
^
MySQLdb/_mysql.c:1650:9: note: did you mean ‘mysql_ping’?
/usr/local/Cellar/mysql/8.3.0_1/include/mysql/mysql.h:525:13: note: ‘mysql_ping’ declared here
int STDCALL mysql_ping(MYSQL *mysql);
^
MySQLdb/_mysql.c:1859:9: error: call to undeclared function ‘mysql_shutdown’; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
r = mysql_shutdown(&(self->connection), SHUTDOWN_DEFAULT);
^
3 errors generated.
error: command ‘/usr/bin/clang’ failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mysqlclient
Failed to build mysqlclient
ERROR: Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects


错误二:



  running build_ext
  building 'MySQLdb.\_mysql' extension
  creating build/temp.macosx-14-x86_64-cpython-39
  creating build/temp.macosx-14-x86_64-cpython-39/MySQLdb
  clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/readline/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Wno-implicit-function-declaration -I/usr/local/opt/mysql-client/include -Dversion\_info=(1,4,4,'final',0) -D\_\_version\_\_=1.4.4 -I/usr/local/opt/mysql-client/include/mysql -I/Users/skyler/Documents/py-env/include -I/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c MySQLdb/_mysql.c -o build/temp.macosx-14-x86_64-cpython-39/MySQLdb/_mysql.o
  clang -bundle -undefined dynamic_lookup -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -L/usr/local/opt/mysql-client/lib -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/bzip2/include -I/usr/local/opt/readline/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include -Wno-implicit-function-declaration -I/usr/local/opt/mysql-client/include build/temp.macosx-14-x86_64-cpython-39/MySQLdb/_mysql.o -L/usr/local/opt/mysql-client/lib -lmysqlclient -lz -lzstd -lssl -lcrypto -lresolv -o build/lib.macosx-14-x86_64-cpython-39/MySQLdb/_mysql.cpython-39-darwin.so
  ld: library 'zstd' not found
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command '/usr/bin/clang' failed with exit code 1
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for mysqlclient
Failed to build mysqlclient
ERROR: Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects


### 解决方法


系统需要提前安装必要的lib,例如


* brew install mysql-client
	+ (mysql服务还是可以通过 brew install mysql去使用)
* brew install openssl@1.1
* brew install zstd
* (pip install 是提示ld: library ‘xxx’ not found就安装啥)



设置编译依赖

export CPPFLAGS=“-I ( b r e w − − p r e f i x o p e n s s l @ 1.1 ) / i n c l u d e − I (brew --prefix openssl@1.1)/include -I (brewprefixopenssl@1.1)/includeI(brew --prefix libffi)/include -I ( b r e w − − p r e f i x r e a d l i n e ) / i n c l u d e − I (brew --prefix readline)/include -I (brewprefixreadline)/includeI(brew --prefix zstd)/include”
export CFLAGS=“-I ( b r e w − − p r e f i x o p e n s s l @ 1.1 ) / i n c l u d e − I (brew --prefix openssl@1.1)/include -I (brewprefixopenssl@1.1)/includeI(brew --prefix bzip2)/include -I ( b r e w − − p r e f i x r e a d l i n e ) / i n c l u d e − I (brew --prefix readline)/include -I (brewprefixreadline)/includeI(xcrun --show-sdk-path)/usr/include -Wno-implicit-function-declaration -I ( b r e w − − p r e f i x z s t d ) / i n c l u d e " e x p o r t L D F L A G S = " − L (brew --prefix zstd)/include" export LDFLAGS="-L (brewprefixzstd)/include"exportLDFLAGS="L(brew --prefix openssl@1.1)/lib -L ( b r e w − − p r e f i x r e a d l i n e ) / l i b − L (brew --prefix readline)/lib -L (brewprefixreadline)/libL(brew --prefix zlib)/lib -L ( b r e w − − p r e f i x b z i p 2 ) / l i b − L (brew --prefix bzip2)/lib -L (brewprefixbzip2)/libL(brew --prefix gettext)/lib -L ( b r e w − − p r e f i x l i b f f i ) / l i b − L (brew --prefix libffi)/lib -L (brewprefixlibffi)/libL(brew --prefix zstd)/lib”

执行安装

pip install mysqlclient==1.4.4


按照如此执行可以安装成功。


### 其他问题


**自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。**

**深知大多数Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!**

**因此收集整理了一份《2024年Python开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。**

![img](https://img-blog.csdnimg.cn/img_convert/78f28fde98e5369b93da66011a2a586c.png)

 

![img](https://img-blog.csdnimg.cn/img_convert/7d2874e98e7ae41b0b39648e496c4356.png)

![img](https://img-blog.csdnimg.cn/img_convert/46506ae54be168b93cf63939786134ca.png)

![img](https://img-blog.csdnimg.cn/img_convert/252731a671c1fb70aad5355a2c5eeff0.png)

![img](https://img-blog.csdnimg.cn/img_convert/6c361282296f86381401c05e862fe4e9.png)

![img](https://img-blog.csdnimg.cn/img_convert/9f49b566129f47b8a67243c1008edf79.png)

 

**既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上前端开发知识点,真正体系化!**

**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**

**如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注Python)**

95%以上前端开发知识点,真正体系化!**

**由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新**

**如果你觉得这些内容对你有帮助,可以扫码获取!!!(备注Python)**

<img src="https://img-community.csdnimg.cn/images/fd6ebf0d450a4dbea7428752dc7ffd34.jpg" alt="img" style="zoom:50%;" />
  • 9
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值