`
Billy_Ao
  • 浏览: 12560 次
  • 性别: Icon_minigender_1
最近访客 更多访客>>
社区版块
存档分类
最新评论

Install Mysql-Python on Windows

阅读更多
收入两个安装关于安装MySQLdb的URL

http://stackoverflow.com/questions/645943/mysql-for-python-in-windows

As Python newbie learning the Python ecosystem I've just completed this.

Install setuptools instructions

Install MySQL 5.1. Download the 97.6MB MSI from here You can't use the essentials version because it doesnt contain the C libraries.
Be sure to select a custom install, and mark the development tools / libraries for installation as that is not done by default. This is needed to get the C header files.
You can verify you have done this correctly by looking in your install directory for a folder named "include". E.G C:\Program Files\MySQL\MySQL Server 5.1\include. It should have a whole bunch of .h files.

Install Microsoft Visual Studio C++ Express 2008 from here This is needed to get a C compiler.

Open up a command line as administrator (right click on the Cmd shortcut and then "run as administrator". Be sure to open a fresh window after you have installed those things or your path won't be updated and the install will still fail.

From the command prompt:

easy_install -b C:\temp\sometempdir mysql-python

That will fail - which is OK.

Now open site.cfg in your temp directory C:\temp\sometempdir and edit the "registry_key" setting to:

registry_key = SOFTWARE\MySQL AB\MySQL Server 5.1

now CD into your temp dir and:

python setup.py clean

python setup.py install

You should be ready to rock!

Here is a super simple script to start off learning the Python DB API for you - if you need it.

http://hi.baidu.com/koflance/blog/item/78ae37f90f66c615a9d311f3.html

Now try to build it again. I got this :

error: build\temp.win32-2.6\Release\_mysql.pyd.manifest : general error c1010070: Failed to load and parse the manifest.

The system cannot find the file specified. error: command ‘mt.exe’ failed with exit status 31 To fix this problem, go to C:\Python26\Lib\distutils, edit msvc9compiler.py, search for ‘MANIFESTFILE’, you will find the following line ld_args.append(’/MANIFESTFILE:’ + temp_manifest) Then append the following line after the above line, ld_args.append(’/MANIFEST’) Then go back to run “setup.py build”, it will succeed.

Finally, run setup.py install Test it in python >>> import MySQLdb >>>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics