pythonmysqllibmysqlclient

Cannot install mysqlclient on MacOS 14


I need to install mysqlclient for python, so I use command pip install mysqlclient, but I get following:

In file included from src/MySQLdb/_mysql.c:29:
      /opt/homebrew/Cellar/mysql/8.3.0_1/include/mysql/mysql.h:46:10: fatal error: 'sys/types.h' file not found
      #include <sys/types.h>
               ^~~~~~~~~~~~~

After I set environment variable,

export set CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/"

it fails with different error:

error: unable to create target: 'No available targets are compatible with triple "x86_64-apple-macosx10.9.0"'
      1 error generated.

And when I set variable following way:

export set CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ -mmacosx-version-min=14.4"

I get similar error.

Has anyone run into this issue?


Solution

  • Instead of usage of mysqlclient, it indeed might be better option to use mysql-connector:

    pip install mysql-connector-python
    

    I needed it for Django, so I replaced Django database engine with mysql.connector.django.

    Yet enother option is discussed here. Also workable.