【问题标题】:Python: How to install mysqldb on windows 7 x64?Python:如何在 Windows 7 x64 上安装 mysqldb?
【发布时间】:2011-07-14 03:22:36
【问题描述】:

我正在尝试在 windows x64 上安装 Mysql-python

我安装了python x64setuptools(检查了leaf库,安装成功)但是我无法安装mysqldb 。 我试图执行

C:\Users\Fedcomp\Desktop\leaf-0.4\MySQL-python-1.2.3>python 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,但抓住了这个(安装了 MS Visual express)

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 python x64python x86 编译 mysqldb 吗?

【问题讨论】:

    标签: python mysql windows-7 64-bit


    【解决方案1】:

    编辑mysqlclientPyPI 上有 32 位和 64 位的二进制包。它是 MySQL-python 的一个分支,自 2014 年以来就没有发布过。

    原始答案留给后人:

    您可以找到二进制安装程序 here (Python 2.6-3.2)、here (2.7) 或 here (2.6)。请注意,您不必在 Windows x64 上使用 64 位 Python。您也可以使用 Python 的 32 位构建,其中有更多预构建的 3rd 方包。

    【讨论】:

    • +1 很好。我会支持使用 32 位的建议。它确实让生活更轻松。
    • 如果您已经安装了另一个版本,那么我建议您先删除并安装正确的版本。
    • 只是一个小评论:我尝试了第一个链接,但它无法连接到我的数据库(python 2.7 版本)。但是第二个链接的驱动程序工作正常。
    • 这太棒了,我花了很长时间才找到它。谢谢!
    • 这是一个很好的建议,但如果 mysql 数据库是 64 位,那么驱动程序将无法与 mysql 一起使用。
    【解决方案2】:

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

    【讨论】:

    【解决方案3】:

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

    但是,如果您使用的是 64 位 Python,那么您将需要 64 位编译器,而 Express 没有 64 位版本。您可以下载 SDK MSVC 编译器并进行配置,但它的工作量很大。

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

    编辑

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

    【讨论】:

      猜你喜欢
      • 2013-10-30
      • 1970-01-01
      • 2014-05-31
      • 1970-01-01
      • 1970-01-01
      • 2016-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多