1

Previously, my installation works normally, since it uses pip's cache directory. But when I installed a brew package, brew automatically removed mysql-connector-c, and added mysql-client 8.0.19 instead. From that moment, my application can't connect to the DB anymore:

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.

It seems that the MySQL-python package still points to the old mysql-connector-c. I decided to reinstall the package without using the cache:

pip install MySQL-python==1.2.5 --no-cache-dir

But I got this error instead:

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

I have searched for this error, but the answers are usually related to brew install mysql-connector-c, while this package is not available from brew anymore. So how can I handle this exception?

Here is my /usr/local/opt (../Cellar/mysql-client/6.1.11 is invalid since it has been upgraded):

mysql-client -> ../Cellar/mysql-client/8.0.19
mysql-connector-c -> ../Cellar/mysql-client/6.1.11

Should I reinstall the old version of mysql-client to install MySQL-python from cache and keep using the old version? Or is there another way to deal with 'my_config.h' file not found?

1 Answer 1

1

This procedure worked for me (I'm adding the mysql-client and the mysql-connector-c removal to it):

brew remove mysql mysql-client mysql-connector-c
brew install [email protected]
brew link --force [email protected]
pip install mysql-python

I read a post and adjusted the procedure to link things in the /usr/local/bin instead of adding a new route to the PATH variable. Reference: MacOS: "pip install MySQL-python" returning an error: "_mysql.c:44:10: fatal error: 'my_config.h' file not found"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.