简体   繁体   中英

Python: How to install mysqldb on windows 7 x64?

Im trying install Mysql-python on windows x64 .

I installed python x64 , setuptools (checked on the leaf lib, successfully installed) but i can't install mysqldb . I trying to execute

C:\\Users\\Fedcomp\\Desktop\\leaf-0.4\\MySQL-python-1.2.3>python setup.py install

but catch this

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

also trying with msvc but catch this (MS Visual express installed)

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

How to install mysqldb correctly on windows x64? (headers from original mysql installation because, in xampp server they doesn't exist)

Or may someone compile mysqldb for windows python x64 or python x86 ?

EDIT : mysqlclient has binary packages for both 32bit and 64bit on PyPI . It's a fork of MySQL-python, which hasn't seen a release since 2014.

Original answer left for posterity:

You can find binary installers here (Python 2.6-3.2), here (2.7) or here (2.6). Note that you don't have to use 64bit Python on Windows x64. You can just as well use a 32bit build of Python, for which there are more pre-built 3rd party packages around.

I'm not 100% sure, but I think your path variables are to blame. It seems the compiler isn't found, run a search for vcvarsall.bat and double click it, it should correctly set your path variables. And then try to install again your package. If you can't find vcvarsall.bat, reinstall MS Visual Express again.

"Unable to find vcvarsall.bat" means that you haven't got the necessary Visual Studio directories in your path.

However, if you are using 64 bit Python then you'll need a 64 bit compiler and Express doesn't come in 64 bit flavours. You could download the SDK MSVC compiler and get that configured but its very hard work.

If I was you I'd switch to 32 bit Python and you can almost surely get pre-built binaries.

EDIT

Pre-built 64 bit binaries as found by piquadrat would be even simpler!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM