title: Unable to install mysqlclient Python package on Windows
body: <p>I am trying to install the <code>mysqlclient</code> Python package (<a href="https://pypi.python.org/pypi/mysqlclient" rel="nofollow noreferrer">https://pypi.python.org/pypi/mysqlclient</a>) into a virtual Python 2.7 environment on Windows 7 (on a local PC, and on the Appveyor CI) and cannot get it done.</p>
  
  <p>I am describing the issues for the local PC with Win 7, but it happens basically the same way on Appveyor.</p>
  
  <p>Packages in my virtualenv when I start:</p>
  
  <pre><code>pip (9.0.1)
  setuptools (36.6.0)
  wheel (0.30.0)
  </code></pre>
  
  <p><code>pip install mysqlclient</code> initially says:</p>
  
  <pre><code>. . .
  running build_ext
  building '_mysql' extension
  error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
  </code></pre>
  
  <p>Apparently, Python 2.7 requires VC9. After installing it, <code>pip install mysqlclient</code> gets a little further, but misses include files:</p>
  
  <pre><code>. . .
  building '_mysql' extension
  creating build\temp.win-amd64-2.7
  creating build\temp.win-amd64-2.7\Release
  C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -IC:\Python27\include -IC:\Users\Andi\virtualenvs\mysqlclient\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release\_mysql.obj /Zl
  _mysql.c
  _mysql.c(29) : fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Common Files\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2
  </code></pre>
  
  <p>In order to get the header files, I installed the "MySQL Connector/C 6.1.10" from <a href="https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.10-winx64.msi" rel="nofollow noreferrer">https://downloads.mysql.com/archives/get/file/mysql-connector-c-6.1.10-winx64.msi</a>. This is admittedly only the second latest version, but I need to install it on Appveyor from the command line, and did not find out how to download the latest version in an unattended manner.</p>
  
  <p>Also, using the MSI installer installs the package in <code>C:\Program Files\MySQL\MySQL Connector C 6.1</code> but the build step in pip install expects it in <code>C:\Program Files (x86)\MySQL\MySQL Connector C 6.1</code>, so I softlinked it:</p>
  
  <pre><code>mklink /D "C:\Program Files (x86)\MySQL\MySQL Connector C 6.1" "C:\Program Files\MySQL\MySQL Connector C 6.1"
  </code></pre>
  
  <p>When looking at the files in that version of the MySQL Connector/C, it has only lib/vs12 and lib/vs14 directories:</p>
  
  <pre><code>lib/vs12/mysqlclient.lib
  lib/vs14/mysqlclient.lib
  </code></pre>
  
  <p>As expected, <code>pip install mysqlclient</code> now gets beyond the compiles, but fails when linking:</p>
  
  <pre><code>. . .
  running build_ext
  building '_mysql' extension
  creating build\temp.win-amd64-2.7
  creating build\temp.win-amd64-2.7\Release
  C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -IC:\Python27\include -IC:\Users\Andi\virtualenvs\mysqlclient\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release\_mysql.obj /Zl
  _mysql.c
  _mysql.c(242) : .... several warnings ...
  C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO "/LIBPATH:C:\Program Files (x86)\MySQL\MySQL Connector C 6.1\lib\vs9" /LIBPATH:C:\Python27\Libs /LIBPATH:C:\Users\Andi\virtualenvs\mysqlclient\libs /LIBPATH:C:\Users\Andi\virtualenvs\mysqlclient\PCbuild\amd64 /LIBPATH:C:\Users\Andi\virtualenvs\mysqlclient\PC\VS9.0\amd64 kernel32.lib advapi32.lib wsock32.lib mysqlclient.lib /EXPORT:init_mysql build\temp.win-amd64-2.7\Release\_mysql.obj /OUT:build\lib.win-amd64-2.7\_mysql.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\_mysql.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\_mysql.pyd.manifest /MANIFEST
  LINK : fatal error LNK1181: cannot open input file 'mysqlclient.lib'
  error: command 'C:\\Program Files (x86)\\Common Files\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1181
  </code></pre>
  
  <p>I did not find a version of the "MySQL Connector/C" package that can still be downloaded and that works with VC9. Using the mysqlclient.lib files in the vs12 or vs14 directories in this vc9 build results in unresolved symbols.</p>
  
  <p><strong>My questions are:</strong></p>
  
  <ul>
  <li>What package(s) do I need to use in order to get the right header files (e.g. <code>mysql.h</code>) and libraries (e.g. <code>mysqlclient.lib</code>) for a successful <code>pip install mysqlclient</code> on Windows 7?</li>
  <li>More generally, what are the prerequisites for a successful <code>pip install mysqlclient</code> on Windows 7?</li>
  </ul>