Python:如何在Windows 7 x64上安装mysqldb?
我正在尝试在windows x64上安装Mysql-python。
我已经安装了python x64和setuptools(在leaf库中检查过,安装成功),但是我无法安装mysqldb。
我尝试执行
C:\Users\Fedcomp\Desktop\leaf-0.4\MySQL-python-1.2.3>python setup.py install
但是遇到了这个问题
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?
(因为在xampp服务器中没有原始mysql安装的头文件)或者有没有人能为windows的python x64或python x86编译mysqldb?
3 个回答
1
“找不到 vcvarsall.bat” 的意思是你的系统路径中没有必要的 Visual Studio 目录。
不过,如果你使用的是 64 位的 Python,那么你需要一个 64 位的编译器,而 Express 版本并没有 64 位的选项。你可以下载 SDK 的 MSVC 编译器并进行配置,但这会非常麻烦。
如果我是你,我会换成 32 位的 Python,这样几乎可以肯定能找到现成的二进制文件。
编辑
像 piquadrat 找到的那样,现成的 64 位二进制文件会更简单!
2
我不是百分之百确定,但我觉得你的路径变量可能有问题。看起来编译器找不到,试着搜索一下 vcvarsall.bat 文件,然后双击它,这样应该能正确设置你的路径变量。然后再试着重新安装你的软件包。如果找不到 vcvarsall.bat,那就重新安装一下 MS Visual Express。