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

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


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.

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

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


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


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.

site.cfg:

# 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' ]...