解決mac _mysql.c:44:10: fatal error: ‘my_config.h‘ file not found

環境:
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 包也應該更新一下,做個兼容。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章