Monday, December 22, 2014

Properly Installing MySQLdb python package in Windows environment

A few problems can happen when you install MySQLdb python package in Windows. I summarize the problems and their solutions here:
  1. You should install Pythonxy, and install it on your computer using complete installation
  2. type "pip install MySQL-python" in your windows command line window, you may have the following problem: "unable to find vcvarsall.bat". This is because python can't find the visual studio C++ compiler properly. Execute the following command based on the version of Visual Studio installed:
    • Visual Studio 2010 (VS10): SET VS90COMNTOOLS=%VS100COMNTOOLS%
    • Visual Studio 2012 (VS11): SET VS90COMNTOOLS=%VS110COMNTOOLS%
    • Visual Studio 2013 (VS12): SET VS90COMNTOOLS=%VS120COMNTOOLS%
  3. After setting the C++ compiler correctly, you may have the following problem: "Cannot open include file: 'config-win.h'". This is because MySQL Connector was not installed or is not configured properly. Install MySQL Connector, and you can refer to the following post for configuration: http://stackoverflow.com/questions/1972259/mysql-python-install-problem-using-virtualenv-windows-pip

If you can read Chinese, actually this post is a good summary:
http://f.dataguru.cn/thread-133159-1-1.html