以前,我的安装工作正常,因为它使用的是pip的缓存目录。但当我安装brew软件包时,brew自动删除MySQL-连接器-c,并添加mysql 8.0.19。从那时起,我的应用程序就不能再连接到DB了:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dlopen([venv_location]/lib/python2.7/site-packages/_mysql.so, 2):
Library not loaded: /usr/local/opt/mysql-connector-c/lib/libmysqlclient.18.dylib
Referenced from: [venv_location]/lib/python2.7/site-packages/_mysql.so Reason: image not found.看来MySQL-python包仍然指向旧的mysql-连接器-c。我决定在不使用缓存的情况下重新安装包:
pip install MySQL-python==1.2.5 --no-cache-dir但是我得到了这个错误:
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/include -arch x86_64 -pipe -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/local/opt/mysql-client/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.7/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我已经搜索了这个错误,但是答案通常是与brew安装mysql有关,而这个包不再可以从brew中获得。那么我该如何处理这个异常呢?
以下是my /usr/local/opt (./c业力/mysql-client/6.1.11已升级后无效):
mysql-client -> ../Cellar/mysql-client/8.0.19
mysql-connector-c -> ../Cellar/mysql-client/6.1.11我是否应该重新安装MySQL的旧版本,以便从缓存中安装MySQL并继续使用旧版本?或者有其他方法来处理'my_config.h‘文件找不到
发布于 2022-03-09 22:07:35
这个过程对我有效(我正在向它添加mysql-客户机和mysql连接器-c删除):
brew remove mysql mysql-client mysql-connector-c
brew install mysql@5.7
brew link --force mysql@5.7
pip install mysql-python我读了一篇文章,并调整了过程,使之链接到/usr/local/bin中,而不是向PATH变量中添加新的路由。参考资料:MacOS: "pip install MySQL-python" returning an error: "_mysql.c:44:10: fatal error: 'my_config.h' file not found"
https://stackoverflow.com/questions/61883175
复制相似问题