[ACCEPTED]-Cannot open include file: 'config-win.h': No such file or directory" while installing mysql-python-mysql-python

Accepted answer
Score: 93

All I had to do was go over to oracle, and 11 download the MySQL Connector C 6.0.2 (newer doesn't work!) and 10 do the typical install.


Be sure to include 9 all optional extras (Extra Binaries) via 8 the custom install, without these it did 7 not work for the win64.msi

Once that was 6 done, I went into pycharms, and selected 5 the MySQL-python>=1.2.4 package to install, and 4 it worked great. No need to update any 3 configuration or anything like that. This 2 was the simplest version for me to work 1 through.

Hope it helps

Score: 25

The accepted solution no longer seems to 5 work for newer versions of mysql-python. The 4 installer no longer provides a site.cfg file to 3 edit.

If you are installing mysql-python 2 it'll look for C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include. If you have a 64-bit installation 1 of MySQL, you can simply invoke:

  1. mklink /d "C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" "C:\Program Files\MySQL\MySQL Connector C 6.0.2\include"
  2. Run pip install mysql-python
  3. Delete the symbolic link created in step 1
Score: 18

Update for mysql 5.5 and config-win.h not 14 visible issue

In 5.5 config-win. has actually 13 moved to Connector separate folder in windows. i.e. smth 12 like:

C:\Program Files\MySQL\Connector C 11 6.0.2\include

To overcome the problem one 10 need not only to download "dev bits" (which 9 actually connects the connector) but also to modify 8 mysqldb install scripts to add the include 7 folder. I've done a quick dirty fix as that.


# Windows connector libs for MySQL.
connector = C:\Program Files\MySQL\Connector C 6.0.2

in 6 setup_windows.py locate the line

include_dirs = [ os.path.join(mysql_root, r'include') ]:

and add:

include_dirs = [ os.path.join(options['connector'], r'include') ]

after 5 it.

Ugly but works until mysqldb authors 4 will change the behaviour.

Almost forgot 3 to mention. In the same manner one needs 2 to add similar additional entry for libs:

library_dirs = [ os.path.join(options['connector'], r'lib\opt') ]

i.e. your 1 setup_windows.py looks pretty much like:

library_dirs = [ os.path.join(mysql_root, r'lib\opt') ]
library_dirs = [ os.path.join(options['connector'], r'lib\opt') ]
libraries = [ 'kernel32', 'advapi32', 'wsock32', client ]
include_dirs = [ os.path.join(mysql_root, r'include') ]
include_dirs = [ os.path.join(options['connector'], r'include') ]
extra_compile_args = [ '/Zl' ]
Score: 15

The accepted answer is out of date. Some 10 of the suggestions were already incorporated 9 in the package, and I was still getting 8 the error about missing config-win.h & mysqlclient.lib.

  • Install 7 mysql-connector-c-6.0.2-win32.msi

    There's a zip file for the conenctor too 6 but that didn't work because mysqlclient.lib is in lib directory 5 whereas the installer expects it in lib/opt. Instead 4 of hacking site.cfg or setup_windows.py, the msi 3 does the job.

  • pip install mysql-python

P.S. Since 2 I don't use MySQL anymore, my answer may 1 be out of date as well.

Score: 11

I know this post is super old, but it is 15 still coming up as the top hit in google 14 so I will add some more info to this issue.

I 13 was having the same problems as OP but none 12 of the suggested answers seemed to work 11 for me. Mainly because "config-win.h" didn't 10 exist anywhere in the connector install 9 folder.

I was using the latest Connector 8 C 6.1.6 as that was what was suggested by 7 the MySQL installer.

This however doesn't 6 seem to be supported by the latest MySQL-python 5 package (1.2.5). When trying to install 4 it I could see that it was explicitly looking 3 for C Connector 6.0.2.

"-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include"

So by installing 2 this version from https://dev.mysql.com/downloads/file/?id=378015 the python package installed 1 without any problem.

Score: 7

Most probably the answer is to install MySQL 6 Developer Build and selecting "C headers\libs" option 5 during configuration. (as reported in this 4 entry: Building MySQLdb for Python on Windows 3 on rationalpie.wordpress.com)

Maybe even 2 better solution is to install a precompiled 1 build: http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe

Score: 5

If pip fails to install "MySQLdb", a 6 workaround is to download and install it 5 on your machine first from this link


then 4 copy all MySQL* and _mysql* files and directories 3 from your system Python to your Virtualenv 2 dir:

c:\Python27\Lib\site-packages (or similar path to your system Python) to c:\my_virtenv\Lib\site-packages (path 1 to your virtualenv)

Score: 4

Well, if you are still having the problem, you 1 can download the installer from http://code.google.com/p/soemin/downloads/detail?name=MySQL-python-1.2.3.win32-py2.7.exe

Score: 4

I had a lot of headache with MySQLdb too.

Why 2 not use the official MysQL Python Connector?

easy_install mysql-connector-python

Or 1 you can download it from here: http://dev.mysql.com/downloads/connector/python/

Documentation: http://dev.mysql.com/doc/refman/5.5/en/connector-python.html

Score: 3

Installing dev bits for mysql got rid of 5 the config-win.h error I was having, and threw another. Failed to load and parse the manifest. The system cannot find the file specified. I 4 found the answer to my problem in this post: http://www.fuyun.org/2009/12/install-mysql-for-python-on-windows/.

I 3 copied the file 'C:\Python26\Lib\distutils\msvc9compiler.py` into 2 my virtualenv, made the edit suggested in 1 the above link, and things are working fine.

Score: 3

Simplest working solution:

Download the MySQL Connector C 6.0.2 from below link and Install.


After 5 installing the MySQL Connector C 6.0.2, copy 4 the folder "MySQL Connector C 6.0.2" from 3 "C:\Program Files\MySQL" to "C:\Program 2 Files (x86)\MySQL".

Then type

pip install MySQL-python

It will 1 definitely work.

Score: 2

In my case, my fix was copying the folder 13 created from mysql-connector-c-6.0.2-win32.msi 12 (referenced from username buffer in a previous 11 post), which is located at c:\Program Files\MySQL\MySQL 10 Connector C 6.0.2 and creating a new path 9 with Program Files (x86) and pasting the 8 content there since the installation is 7 not properly checking between 32-bit and 6 64-bit machines.

So, the new path is C:\Program 5 Files (x86)\MySQL\MySQL Connector C 6.0.2. This 4 is the path that the installer is looking 3 to find, so I pasted the files there to 2 help the installer to find the files, which 1 was causing the error about missing config-win.h

Score: 2

Steps for Window10:

  • Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
  • Download the right version according to python version and hardware specs: for my case, mysqlclient‑1.4.2‑cp37‑cp37m‑win32.whl works for python3.7 and Intel CPU.
  • While your env is still activated, go to the download folder and run pip install mysqlclient-1.4.2-cp37-cp37m-win32.whl


Score: 1

Try ActivePython,

pypm -E C:\myvirtualenv install mysql-python


Score: 1

I did follow the answer from Bugagotti, And 9 it does not work in my windows (Win7 64 8 bit, py27 and have mysql connector 6.1 installed) for 7 mysql-python-1.2.5, so I made some even 6 dirty changes inside mysql-python-1.2.5:

First, the 5 site.cfg:

connector = C:\Program Files\MySQL\MySQL Connector C 6.1

Second, the _mysql.c :

#if defined(MS_WINDOWS)
#include <config-win.h>
#include "my_config.h"


#if 0 /*defined(MS_WINDOWS)*/
#include <config-win.h>
#include "my_config.h"

And with 4 these changes ,the config_win.h issue will 3 gone, but there is still a link issue:

LINK : fatal error LNK1181: cannot open input file 'mysqlclient.lib'

For 2 this, I changed the setup_windows.py:

library_dirs = [ os.path.join(connector, r'lib\vs9') ]  ## the original value was r'lib\opt'

Then 1 it worked finally.

Score: 1

I followed Mingcai SHEN's method.

But in 8 my case, I changed the connector to

connector = C:\Program Files\MySQL\MySQL Connector.C 6.1

And the 7 library_dirs is changed to

library_dirs = [ os.path.join(connector, r'lib\vs10') ]

because I don't 6 have a vs9 directory. It works, but I don't know why.

I have 5 vs2012 installed, and the lib directory 4 of the connector only has vs10 and vs11, in which 3 vs11 doesn't work. The VCForPyhton27.mis I installed 2 seems to support vs9.

Anyway, this works. And 1 if you want to risk it, you can try.

Score: 1

Solution that worked for me on Windows: Install 2 both the 32-bit and 64-bit versions of the MySQL Connector/C 6.0.2. Open 1 Command Prompt and run:

pip install mysql-python
Score: 1

For me the following approach solved the 5 issue (Python 3.5.2; mysqlclient 1.3.9):

  1. Dowload latest MySQL C Connector http://dev.mysql.com/downloads/connector/c/ (for me was Windows (x86, 64-bit), MSI Installer)
  2. Copy c:\Program Files\MySQL\MySQL Connector C 6.0.2\ directory to c:\Program Files (x86)\MySQL\MySQL Connector C 6.1\
  3. Run pip install mysqlclient
  4. [optional] delete c:\Program Files (x86)\MySQL\MySQL Connector C 6.1\

The 4 issue here is only for x64 bit installation 3 owners, since build script is trying to 2 locate C connector includes in x86 program 1 files directory.

Score: 1
building '_mysql' extension
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
C:\Users\TimHuang\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python27\include -Ic:\python27\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release\_mysql.obj /Zl
_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory

If you see this when you try pip install mysql-python, the easiest 3 way is to copy

C:\Program Files\MySQL\MySQL Connector C 6.0.2 to C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2

I tried to create the 2 symbolic link but Windows keeps throwing 1 me C:\WINDOWS\system32>mklink /d "C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" "C:\Program Files\MySQL\MySQL Connector C 6.0.2\include" The system cannot find the path specified.

Score: 0

If you are doing this in a virtual environment 2 whether using Visual Studio or otherwise, try 1 easy_install MySQL-python

Score: 0
  1. Download from this

  2. Then install this whl 3 by pip installer. Shift + right click in 2 Downloaded folder and choose Open powershell here. Then install 1 using command: pip install package_name.whl

Score: 0

Download the version of Connector from https://dev.mysql.com/downloads/connector/c/6.0.html For 3 my case I had installed 64 bit of connector 2 and my python was 32 bit. So I had to copy 1 MySQL from program files to Program Files(86)

More Related questions