mysqlclient error – fatal error C1083 Cannot open file ‘mysql.h’: No such file or directory

mysqlclient error – fatal error C1083 Cannot open file ‘mysql.h’: No such file or directory is an error which happens when MySQL Connector is missing.

In this article I am going to explain what happens when you get this error and how you can solve it with a main solution, we will also explore other solutions which can possibly solve the issue.

In the sections bellow we will explain the root of the error more and propose some possible fixes.

Solution 1 : install mysqlclient and its dependencies

First of all, you need to follow the instructions bellow, step by step.

First, follow the link bellow.

https://downloads.mysql.com/archives/c-c/

Install the Archived Version of MySQL Connector/C.

Navigate to the directory bellow on your computer.

                                                                       #
C:\Program Files\MySQL\MySQL Connector C 6.1
                                                                       #

Copy the folder MySQL Connector C 6.1 and its content. To the folder bellow.

                                                                       #
C:\Program Files (x86)\MySQL\MySQL Connector C 6.1
                                                                       #

Now, install mysqlclient using pip3. If this does not work, add the steps bellow.

Download and install mariadb from the link below.

                                                                       #
https://downloads.mariadb.com/Connectors/c/connector-c-3.0.4/
                                                                       #

Copy the content of the following path

                                                                       #
C:\Program Files\MariaDB\MariaDB Connector C 64-bit\include
                                                                       #

Now, past the content to a new folder you should create called mariadb, the folder shoulb be placed in this directory

                                                                       #
C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include\
                                                                       #

Now copy all the content inside this directory.

                                                                       #
C:\Program Files\MariaDB\MariaDB Connector C 64-bit\lib
                                                                       #

Again, create a folder called mariadb and past it to the path bellow.

                                                                       #
`C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib`
                                                                       #

Finally, install mysqlclient using the command bellow.

                                                                       #
pip3 install mysqlclient
                                                                       #

If all of these commands did not work, try to follow the next fix.

Solution 2 : Downgrade Python

The second solution is to downgrade Python.

You can do this directly or through your virtual environment.

Just make sure you follow the official instructions

I hope the solution above fixed your problem, good luck with the scripts to come.

Summing-up mysqlclient error – fatal error C1083 Cannot open file ‘mysql.h’: No such file or directory

Thi is the end of our article, a fresh install of pyaudio if done the proper way is able to solve this issue for most developers including me, I hope you found our article and website useful, never give up, keep creating and keep coding. Errors are normal in our field, cheers.

If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/