Installing MySQL Python Package on Windows

I work in *nix environment but sometimes you may want to test some features on your own Windows desktop either due to access constraints on test or development systems. For example, company not allowing to install the latest packages or non-standard tools or you may be lazy and have setup your own little world on a desktop to do your tests, etc.  Anyway, I needed to install Python MySQL package and installing that package is not as straight forward as installing it on Linux systems.

> python setup.py install

The above one typically takes care of it in *nix environment. But in windows you may see following error
"Unable to find vcvarsall.bat" and if so you should download and install Microsoft Visual C++ Express Edition.  Installing whole Visual SDK kit seem like like a overkill for getting one .BAT file.

Now to install MySQL Python package, download it from sourceforge , gunzip it, untar it and make the following change before running install.



Change registry_key entry in site.cfg file to the entry in Windows registry of MySQL (SOFTWARE\MySQL AB\MySQL Server X.X) where X.X is MySQL Server installed.  Open the Windows regedit and check for the entry (and as always backup the registry first).

Now run
> python setup.py install
and during the installation you should see something like this:

running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info\PKG-INFO
writing top-level names to MySQL_python.egg-info\top_level.txt
writing dependency_links to MySQL_python.egg-info\dependency_links.txt
reading manifest file 'MySQL_python.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'MySQL_python.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
...
...
Processing MySQL_python-1.2.3c1-py2.6-win32.egg
Copying MySQL_python-1.2.3c1-py2.6-win32.egg to c:\python26\lib\site-packages
Adding MySQL-python 1.2.3c1 to easy-install.pth file
Installed c:\python26\lib\site-packages\mysql_python-1.2.3c1-py2.6-win32.egg
Processing dependencies for MySQL-python==1.2.3c1
Finished processing dependencies for MySQL-python==1.2.3c1

Change directory to tests sub-directory and run
> python test_MySQLdb_capabilities.py

HTH,
Shiva

No comments:

Post a Comment