5

I have a django project with Python 3.8 and I am trying to install mysqlclient library through: pip install mysqlclient command. I got this error:

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 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
  1. I tried installation by using wheel file from where ( I tried every wheel from this site ) but I got the error: *...is not a supported wheel on this platform.*
  2. I tried to install it from the source but when I run this command python setup.py install I got the same error:
  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 14.0\\VC\\BIN\\cl.exe' failed with exit status 2
  1. I tried this command pip install --only-binary :all: mysqlclient and I got the error:

    Could not find a version that satisfies the requirement mysqlclient (from versions: ) No matching distribution found for mysqlclient

    Please let me know if you have some suggestions. Thank you!

Joshua Varghese
  • 5,082
  • 1
  • 13
  • 34
Ruxi Ierima
  • 81
  • 1
  • 1
  • 6
  • https://stackoverflow.com/search?q=%5Bpip%5D+install+mysqlclient – phd Apr 16 '20 at 09:49
  • Let me explain these errors one by one. "*Cannot open include file: 'mysql.h'*" You need source code of `libmysqlclient`. "*not a supported wheel on this platform*" Either you downloaded a wheel for a different Python version or you have 32/64-bit problem (32-bit Python and 64-bit wheel; or 64-bit Python and 32-bit wheel); download the correct wheel that corresponds to your Python. – phd Apr 16 '20 at 09:52
  • "*Could not find a version that satisfies the requirement mysqlclient (from versions: ) No matching distribution found for mysqlclient*" `mysqlclient` projects [provides wheels](https://pypi.org/project/mysqlclient/1.4.6/#files) only for 64-bit Pythons. Probably you have 32-bit. Install 64-bit Python. – phd Apr 16 '20 at 09:53

1 Answers1

0

Cannot open include file: 'mysql.h': No such file or directory

You are missing the mysql library that is needed as a requirement when compiling mysqlclient from source.

is not a supported wheel on this platform

I bet you have a 32-bit python installed. All the whl files for mysqlclient on pypi are for amd64, which would explain why there is no supported version for your setup. You can check by:

  1. Check your installation path, if it contains something like python38-32, then you have the 32 bit version for sure
  2. Type python in the cmd and check the first line. For me (64 bit python), it contains the string MSC v.1915 64 bit (AMD64)

What you can do about it is uninstall the 32 bit version and install the 64 bit one, after all mysqlclient will not be the last tool that does not have 32 bit whl files available on pypi OR you could download the 32 bit whl file for mysqlclient from here

FlyingTeller
  • 17,638
  • 3
  • 38
  • 53