解决mac

    技术2025-09-10  56

    环境: mac os:10.15.4 mysql:8.0.19 通过Homebrew命令安装 MySQL-python: 1.2.5

    pip install MySQL-python ...... running build_ext building '_mysql' extension creating build/temp.macosx-10.15-x86_64-2.7 cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -iwithsysroot /usr/local/libressl/include -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -I/usr/local/opt/openssl@1.1/include -arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/Cellar/mysql/8.0.19_1/include/mysql -I/Users/zhangli53/.virtualenvs/mega/include/python2.7 -c _mysql.c -o build/temp.macosx-10.15-x86_64-2.7/_mysql.o _mysql.c:44:10: fatal error: 'my_config.h' file not found #include "my_config.h" ^~~~~~~~~~~~~ 1 error generated. error: command 'cc' failed with exit status 1 ---------------------------------------- ERROR: Failed building wheel for MySQL-python

    要安装MySQL-python 包,报错如上,找不到my_config.h文件,那么我就在本电脑上找一下这个文件吧

    find / -name "my_config.h"

    结果是没有这个文件,那么问题就很明显了,去哪找这个头文件? 我在本地电脑查mysql的安装目录,最后发现目录 /usr/local/include/mysql 下有个 mysql.h 文件,这个就应该是我们要找的my_config.h 文件了吧,cp mysql.h my_config.h ,再次 pip install MySQL-python 就已经安装成功了!!!

    我还在想如果这个文件不对,去别个环境拷一个my_config.h 文件过来,安装一下试试呢,结果就成功了。

    我觉得 这个锅应该是新版的mysql来背,文件名瞎改啥? MySQL-python 包也应该更新一下,做个兼容。

    Processed: 0.011, SQL: 9