2011-03-12 67 views
18

我试图安装Mysql-python on windows x64Python:如何在Windows 7 x64上安装mysqldb?

我安装蟒蛇64setuptools的(在 LIB检查,安装成功),但我不能安装MySQLdb的。 我试图执行

C:\用户\ Fedcomp \桌面\叶0.4 \ MySQL的 - 蟒蛇-1.2.3>蟒蛇 的setup.py安装

但赶上这

In file included from _mysql.c:34: 
D:\servers\xampp_server\xampp\mysql\include/config-win.h:211:1: warning: "finite 
" redefined 
D:\servers\xampp_server\xampp\mysql\include/config-win.h:164:1: warning: this is 
the location of the previous definition 
D:\servers\xampp_server\xampp\mysql\include/config-win.h:277:1: warning: "HAVE_S 
TDDEF_H" redefined 
In file included from D:\Python27\include/Python.h:8, 
       from pymemcompat.h:10, 
       from _mysql.c:29: 
D:\Python27\include/pyconfig.h:673:1: warning: this is the location of the previ 
ous definition 
error: command 'gcc' failed with exit status 1 

也与MSVC尝试,但赶上这(安装微软的Visual快递)

C:\Users\Fedcomp\Desktop\leaf-0.4\MySQL-python-1.2.3>python setup.py install bui 
ld --compiler=msvc 
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' 
warning: no files found matching 'MANIFEST' 
warning: no files found matching 'ChangeLog' 
warning: no files found matching 'GPL' 
writing manifest file 'MySQL_python.egg-info\SOURCES.txt' 
installing library code to build\bdist.win-amd64\egg 
running install_lib 
running build_py 
copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb 
running build_ext 
building '_mysql' extension 
error: Unable to find vcvarsall.bat 

如何在Windows x64上正确安装mysqldb? (头从原来的MySQL安装,因为在XAMPP服务器,他们不存在)

或者可能有人为Windows编译蟒蛇64蟒蛇86MySQLdb的

回答

35

编辑mysqlclientPyPI上有32位和64位的二进制包。这是在MySQL-python的,因为2014年

原来的答复为后人留下了还没有见过一个释放的叉:

你可以找到二进制安装here(Python的2.6-3.2),here(2.7)或here(2.6)。请注意,您不必在Windows x64上使用64位Python。您也可以使用Python的32位版本,为此,还有更多预构建的第三方软件包。

+0

+1找到了。我会支持使用32位的建议。它确实让生活更轻松。 – 2011-03-12 17:48:15

+0

如果您已经安装了另一个版本,那么我会建议先删除并安装正确的版本。 – 2013-05-20 11:05:20

+0

只是一个小小的评论:我试过第一个链接,它无法连接到我的数据库(版本为Python 2.7)。但第二个链接的驱动程序正常工作。 – dbf 2013-10-19 17:57:28

1

“无法找到vcvarsall.bat”意味着您的路径中没有必要的Visual Studio目录。

但是,如果您使用的是64位Python,那么您将需要一个64位编译器,并且Express不会采用64位版本。您可以下载SDK MSVC编译器并获得配置,但非常辛苦。

如果我是你,我会切换到32位的Python,你几乎可以肯定会得到预先构建的二进制文件。

编辑

预建如发现piquadrat会更简单的64位二进制文​​件!

1

我不是100%确定,但我认为你的路径变量是怪罪。它似乎没有找到编译器,运行搜索vcvarsall.bat并双击它,它应该正确设置您的路径变量。然后尝试再次安装你的软件包。 如果找不到vcvarsall.bat,请重新安装MS Visual Express。

+4

从这里试试预编译的x64版本的MySQL-python:[用于Python扩展包的非官方Windows二进制文件](http://www.lfd.uci.edu/~gohlke/pythonlibs/) – 2011-03-12 18:04:56