MySQLdb/_mysql.c:521:9: error: call to undeclared function 'mysql_ssl_set'

1.2k Views Asked by At

My system -- Python version -- 3.8.18 and OS version -- macOS ventura 13.6.4

I have an error when I want to install mysqlclient

 pip install  mysqlclient==2.2.0

Error: (full log below)

MySQLdb/_mysql.c:521:9: error: call to undeclared function 'mysql_ssl_set'

I was trying to use mysql 8.0 instead of 8.3 (according to this post pip install mysqlclient fails with "call to undeclared function" error )

Then I created a new env python3.8 -m venv test_venv38

brew install pkg-config // version 0.29.2 
pip install mysqlclient==2.2.0

Error for the last command

File "/private/var/folders/5f/mqmy5hxd2d9_ydtgx8jfch2r0000gn/T/pip-build-env-10bqx287/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 154, in <module>
        File "<string>", line 48, in get_config_posix
        File "<string>", line 27, in find_package_name
      Exception: Can not find valid pkg-config name.
      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
      [end of output]

on the step pip install mysqlclient==2.2.0

Initial error logs:

Building wheels for collected packages: mysqlclient, thriftpy2
  Building wheel for mysqlclient (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for mysqlclient (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [59 lines of output]
      Trying pkg-config --exists mysqlclient
      # Options for building extention module:
        extra_compile_args: ['-I/usr/local/Cellar/mysql/8.3.0/include/mysql', '-std=c99']
        extra_link_args: ['-L/usr/local/Cellar/mysql/8.3.0/lib', '-lmysqlclient']
        define_macros: [('version_info', (2, 2, 0, 'final', 0)), ('__version__', '2.2.0')]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-13-x86_64-cpython-38
      creating build/lib.macosx-13-x86_64-cpython-38/MySQLdb
      copying src/MySQLdb/release.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb
      copying src/MySQLdb/cursors.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb
      copying src/MySQLdb/connections.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb
      copying src/MySQLdb/__init__.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb
      copying src/MySQLdb/times.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb
      copying src/MySQLdb/converters.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb
      copying src/MySQLdb/_exceptions.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb
      creating build/lib.macosx-13-x86_64-cpython-38/MySQLdb/constants
      copying src/MySQLdb/constants/FLAG.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb/constants
      copying src/MySQLdb/constants/CLIENT.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb/constants
      copying src/MySQLdb/constants/__init__.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb/constants
      copying src/MySQLdb/constants/ER.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb/constants
      copying src/MySQLdb/constants/CR.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb/constants
      copying src/MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb/constants
      running egg_info
      writing src/mysqlclient.egg-info/PKG-INFO
      writing dependency_links to src/mysqlclient.egg-info/dependency_links.txt
      writing top-level names to src/mysqlclient.egg-info/top_level.txt
      reading manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      adding license file 'LICENSE'
      writing manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
      copying src/MySQLdb/_mysql.c -> build/lib.macosx-13-x86_64-cpython-38/MySQLdb
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build/temp.macosx-13-x86_64-cpython-38
      creating build/temp.macosx-13-x86_64-cpython-38/src
      creating build/temp.macosx-13-x86_64-cpython-38/src/MySQLdb
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk "-Dversion_info=(2, 2, 0, 'final', 0)" -D__version__=2.2.0 -I/Users/aamoskalenko/0_root_folder/02_dev/13_feast_bitbucket/feast/test_venv38/include -I/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/MySQLdb/_mysql.c -o build/temp.macosx-13-x86_64-cpython-38/src/MySQLdb/_mysql.o -I/usr/local/Cellar/mysql/8.3.0/include/mysql -std=c99
      src/MySQLdb/_mysql.c:524:9: error: call to undeclared function 'mysql_ssl_set'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
              mysql_ssl_set(&(self->connection), key, cert, ca, capath, cipher);
              ^
      src/MySQLdb/_mysql.c:524:9: note: did you mean 'mysql_close'?
      /usr/local/Cellar/mysql/8.3.0/include/mysql/mysql.h:797:14: note: 'mysql_close' declared here
      void STDCALL mysql_close(MYSQL *sock);
                   ^
      src/MySQLdb/_mysql.c:1792:9: error: call to undeclared function 'mysql_kill'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
          r = mysql_kill(&(self->connection), pid);
              ^
      src/MySQLdb/_mysql.c:1792:9: note: did you mean 'mysql_ping'?
      /usr/local/Cellar/mysql/8.3.0/include/mysql/mysql.h:525:13: note: 'mysql_ping' declared here
      int STDCALL mysql_ping(MYSQL *mysql);
                  ^
      src/MySQLdb/_mysql.c:2001:9: error: call to undeclared function 'mysql_shutdown'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
          r = mysql_shutdown(&(self->connection), SHUTDOWN_DEFAULT);
              ^
      3 errors generated.
      error: command '/usr/bin/clang' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mysqlclient
  Building wheel for thriftpy2 (pyproject.toml) ... done
  Created wheel for thriftpy2: filename=thriftpy2-0.4.17-cp38-cp38-macosx_13_0_x86_64.whl size=662548 sha256=951292c9a91c7f1fea19732e135c45aad6129a4cdd99a0c867dadca3bd88d752
  Stored in directory: /Users/aamoskalenko/Library/Caches/pip/wheels/b2/d2/6d/0a47d1a0250236680e0f12b3f3c5093ffc3da4871fe1fa2804
Successfully built thriftpy2
Failed to build mysqlclient
ERROR: Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects
0

There are 0 best solutions below