-1

I am trying to make a fullstack blog application with a flask/sql python backend while using a mac. I cannot get the mysqlclient to download. I followed what it said on https://pypi.org/project/mysqlclient/ and it is still failing. There seems to be a problem with mysql.h $ brew install mysql pkg-config Was successful but the following was not


 pip3 install mysqlclient
Collecting mysqlclient
  Using cached mysqlclient-2.2.0.tar.gz (89 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: mysqlclient
  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
  ╰─> [44 lines of output]
      # Options for building extention module:
        extra_compile_args: ['-I/usr/local/include/mysql', '-std=c99']
        extra_link_args: ['-L/usr/local/lib/mysql']
        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-10.9-universal2-cpython-311
      creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
      copying src/MySQLdb/release.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
      copying src/MySQLdb/cursors.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
      copying src/MySQLdb/connections.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
      copying src/MySQLdb/__init__.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
      copying src/MySQLdb/times.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
      copying src/MySQLdb/converters.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
      copying src/MySQLdb/_exceptions.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb
      creating build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
      copying src/MySQLdb/constants/FLAG.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
      copying src/MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
      copying src/MySQLdb/constants/__init__.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
      copying src/MySQLdb/constants/ER.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
      copying src/MySQLdb/constants/CR.py -> build/lib.macosx-10.9-universal2-cpython-311/MySQLdb/constants
      copying src/MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.9-universal2-cpython-311/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-10.9-universal2-cpython-311/MySQLdb
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build/temp.macosx-10.9-universal2-cpython-311
      creating build/temp.macosx-10.9-universal2-cpython-311/src
      creating build/temp.macosx-10.9-universal2-cpython-311/src/MySQLdb
      gcc -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g -I/usr/local/opt/mysql-client/include "-Dversion_info=(2, 2, 0, 'final', 0)" -D__version__=2.2.0 -I/Library/Frameworks/Python.framework/Versions/3.11/include/python3.11 -c src/MySQLdb/_mysql.c -o build/temp.macosx-10.9-universal2-cpython-311/src/MySQLdb/_mysql.o -I/usr/local/include/mysql -std=c99
      src/MySQLdb/_mysql.c:29:10: fatal error: 'mysql.h' file not found
      #include "mysql.h"
               ^~~~~~~~~
      1 error generated.
      error: command '/usr/bin/gcc' 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
Failed to build mysqlclient
ERROR: Could not build wheels for mysqlclient, which is required to install pyproject.toml-based projects ```
Shadow
  • 33,525
  • 10
  • 51
  • 64
  • 1
    Have you tried installing mysql, e.g. by using brew? https://stackoverflow.com/a/16658287/530160 – Nick ODell Sep 01 '23 at 19:57
  • I have and brew did not work and you cannot download mysqlclient with brew when using a virtual environment – CatLover2291 Sep 01 '23 at 20:10
  • I was there as well :) However, for some time now I never install `PostgreSQL`, `MariaDB`, `MySQL` natively on macos. I use `Docker` based solution only :) – Oo.oO Sep 01 '23 at 20:13
  • Is there a solution you found when you were installing the above Oo.oO? Im trying to learn to use Flask and would like to use a working environment to make it happen? – CatLover2291 Sep 01 '23 at 20:15
  • Brew was successful but when in the venv, pip3 was not successful. – CatLover2291 Sep 01 '23 at 20:16

0 Answers0