“Cannot open include file: 'config-win.h': No such file or directory” while installing mysql-python

0 votes
asked Dec 29, 2009 by saturdayplace

I'm trying to install mysql-python in a virtualenv using pip on windows. At first, I was getting the same error reported here, but the answer there worked for me too. Now I'm getting this following error:

_mysql.c(34) : Fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory

If I symlink (Win7) to my regular (not the virtualenv's) python's site-packages/MySQLdb dir I get

Error loading MySQLdb module: No module named _mysql

I'm rather at a loss here. Any pointers?

19 Answers

0 votes
answered Jan 29, 2009 by saturdayplace

Installing dev bits for mysql got rid of 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 found the answer to my problem in this post: http://www.fuyun.org/2009/12/install-mysql-for-python-on-windows/.

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

0 votes
answered Dec 26, 2010 by chodorowicz

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

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

0 votes
answered Jan 17, 2011 by ethan

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

0 votes
answered Jan 22, 2011 by sridhar-ratnakumar

Try ActivePython,

pypm -E C:\myvirtualenv install mysql-python
0 votes
answered Dec 16, 2011 by bugagotti

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

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

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

To overcome the problem one need not only to download "dev bits" (which actually connects the connector) but also to modify mysqldb install scripts to add the include 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 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 it.

Ugly but works until mysqldb authors will change the behaviour.

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

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

i.e. your 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' ]
0 votes
answered Jan 3, 2013 by yassine-el-badaoui

I had a lot of headache with MySQLdb too.

Why not use the official MysQL Python Connector?

easy_install mysql-connector-python

Or 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

0 votes
answered Jan 7, 2013 by dmitriy

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


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

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

0 votes
answered Jan 8, 2013 by ryan

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

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

0 votes
answered Dec 9, 2013 by gili

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

If you are installing mysql-python it'll look for C:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include. If you have a 64-bit installation 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
0 votes
answered Dec 18, 2013 by kevin-mansel

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


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

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

Hope it helps

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter