Install Mysql-Python on Windows

收入两个安装关于安装MySQLdb的URL

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

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.

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

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 >>>
引用[1]:ERROR: Could not build wheels for opencv-python, which is required to install pyproject.toml-based projects [^1]。引用:ERROR: Could not build wheels for pymssql, which is required to install pyproject.toml-based project。在终端下输入:Python 然后输入import pymssql,如下图所示则表示安装成功了 ~/m/s/code_environment/python_all_package  python  ✔ took 40s base Py at 13:37:20 Python 3.9.13 (main, Aug 25 2022, 18:24:45) [Clang 12.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import pymssql >>> [^2]。 对于错误信息"ERROR: Could not build wheels for MySQL-python, pygraphviz, which is required to install pyproject.toml-based projects",这意味着在安装pyproject.toml-based项目时,无法构建MySQL-python和pygraphviz的wheels。 要解决这个问题,可以尝试以下方法: 1. 确保已正确安装所需的依赖项:MySQL-python和pygraphviz。可以使用pip命令安装它们: ```shell pip install MySQL-python pygraphviz ``` 2. 如果上述命令无法正常工作,可以尝试使用其他安装方法,例如使用conda: ```shell conda install MySQL-python pygraphviz ``` 3. 如果仍然无法解决问题,可以尝试手动安装这些依赖项。可以在官方网站上找到它们的源代码,并按照它们的安装说明进行手动安装。 请注意,安装这些依赖项可能需要满足一些系统要求,例如正确配置数据库连接等。确保按照它们的文档进行正确的配置和安装。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值