2

I already tried to install wheel -- didn't work well.
Tried to install build tools -- didn't work
Tried to install MySQL connector/C and put it in the environment variables -- didn't work
Tried upgrading pip -- didn't work

This is my error:

pip 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
  ╰─> [46 lines of output]
      # Options for building extention module:
        library_dirs: ['C:/mariadb-connector\\lib\\mariadb', 'C:/mariadb-connector\\lib']
        libraries: ['kernel32', 'advapi32', 'wsock32', 'shlwapi', 'Ws2_32', 'crypt32', 'secur32', 'bcrypt', 'mariadbclient']
        extra_link_args: ['/MANIFEST']
        include_dirs: ['C:/mariadb-connector\\include\\mariadb', 'C:/mariadb-connector\\include']
        extra_objects: []
        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.win-amd64-cpython-312
      creating build\lib.win-amd64-cpython-312\MySQLdb
      copying src\MySQLdb\connections.py -> build\lib.win-amd64-cpython-312\MySQLdb
      copying src\MySQLdb\converters.py -> build\lib.win-amd64-cpython-312\MySQLdb
      copying src\MySQLdb\cursors.py -> build\lib.win-amd64-cpython-312\MySQLdb
      copying src\MySQLdb\release.py -> build\lib.win-amd64-cpython-312\MySQLdb
      copying src\MySQLdb\times.py -> build\lib.win-amd64-cpython-312\MySQLdb
      copying src\MySQLdb\_exceptions.py -> build\lib.win-amd64-cpython-312\MySQLdb
      copying src\MySQLdb\__init__.py -> build\lib.win-amd64-cpython-312\MySQLdb
      creating build\lib.win-amd64-cpython-312\MySQLdb\constants
      copying src\MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
      copying src\MySQLdb\constants\CR.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
      copying src\MySQLdb\constants\ER.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
      copying src\MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
      copying src\MySQLdb\constants\FLAG.py -> build\lib.win-amd64-cpython-312\MySQLdb\constants
      copying src\MySQLdb\constants\__init__.py -> build\lib.win-amd64-cpython-312\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.win-amd64-cpython-312\MySQLdb
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build\temp.win-amd64-cpython-312
      creating build\temp.win-amd64-cpython-312\Release
      creating build\temp.win-amd64-cpython-312\Release\src
      creating build\temp.win-amd64-cpython-312\Release\src\MySQLdb
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD "-Dversion_info=(2, 2, 0, 'final', 0)" -D__version__=2.2.0 -IC:/mariadb-connector\include\mariadb -IC:/mariadb-connector\include "-IC:\Users\Administrator\Desktop\Python Projects\tastemates\include" -IC:\Users\Administrator\AppData\Local\Programs\Python\Python312\include -IC:\Users\Administrator\AppData\Local\Programs\Python\Python312\Include "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.38.33130\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22621.0\\cppwinrt" /Tcsrc/MySQLdb/_mysql.c /Fobuild\temp.win-amd64-cpython-312\Release\src/MySQLdb/_mysql.obj
      _mysql.c
      src/MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.38.33130\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [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
6
  • github.com/PyMySQL/mysqlclient/issues/672 Commented Dec 12, 2023 at 14:12
  • 1
    The wheel was missed for release, issue contains test wheel for Python 3.12 Commented Dec 12, 2023 at 14:13
  • Sorry sir what does this mean? I can't install mysqlclient to python 3.12? Commented Dec 12, 2023 at 14:25
  • this means the developer of the library missed 3.12 wheel which is required for it to work. You can either wait until it is fixed or download test wheel provided in one of the posts in the issue I linked. Commented Dec 12, 2023 at 14:29
  • So either I change back to older version of python where the test wheel is provided? Commented Dec 12, 2023 at 14:34

2 Answers 2

0

On Linux/Ubuntu - mysql.h is missing, so install "sudo apt install libmysqlclient-dev" (Centos - sudo yum install mysql-devel -y)

On Windows, it's simply a matter of installing the MySQL client.

References:

  1. mysql.h file can't be found
  2. pip install mysqlclient returns "fatal error C1083: Cannot open file: 'mysql.h': No such file or directory
Sign up to request clarification or add additional context in comments.

Comments

-1

Try:

pip install mysql-connector-python

1 Comment

Welcome to Stack Overflow! Thank you for your answer. Please provide more details about your solution. Code snippets, high quality descriptions, or any relevant information would be great. Clear and concise answers are more helpful and easier to understand for everyone. Edit your answer with specifics to raise the quality of your answer. For more information: How To: Write good answers. Happy coding!

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.