【发布时间】:2020-05-19 04:18:31
【问题描述】:
以前,我的安装工作正常,因为它使用 pip 的缓存目录。但是当我安装了一个brew包时,brew自动删除了mysql-connector-c,并添加了mysql-client 8.0.19。从那一刻起,我的应用程序就无法再连接到数据库了:
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-connector-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 install mysql-connector-c 有关,而 brew 不再提供此包。那么我该如何处理这个异常呢?
这是我的 /usr/local/opt(../Cellar/mysql-client/6.1.11 已升级无效):
mysql-client -> ../Cellar/mysql-client/8.0.19
mysql-connector-c -> ../Cellar/mysql-client/6.1.11
我应该重新安装旧版本的 mysql-client 以从缓存中安装 MySQL-python 并继续使用旧版本吗?或者有没有其他方法来处理 'my_config.h' 文件未找到?
【问题讨论】:
标签: python mysql pip mysql-python