It took me quite a while to figure out how to build and install MySQL for Python (MySQLdb) on Windows. I’d better write it down.
There is no binary distribution of MySQLdb for Python 2.6 on Windows. I have to build it from the source. My environment is Windows XP. MySQL 5.1. Python 2.6 (windows version, not cygwin), and MySQL-python-1.2.3c1. Also, I have Microsoft Visual C++ 2008 Express Edition (Microsoft Visual Studio 9.0) installed, which is required to compile the C code in MySQL-python.
First of all, install Python setuptools, if you haven’t installed it. It is required in MySQL-python setup.py. I also added C:Python26Scripts into environment PATH, where easy_install is installed.
Then, make sure you have MySQL Developer Components installed. Download MySQL msi installer version, select “Developer Components” in Custom Setup. It will install C:Program FilesMySQLMySQL Server 5.1include, libdebug and libopt for you. They are not installed by default.
Uncompress MySQL-python-1.2.3c1.tar.gz into a directory. Open a command window (cmd), change to the directory.
Try to run,
setup.py build
I got this error in setup_windows.py:
in get_config
serverKey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, options['registry_key'])
WindowsError: [Error 2] The system cannot find the file specified
So I edited site.cfg, changed the MySQL version from 5.0 to 5.1 (since I am using 5.1)
registry_key = SOFTWAREMySQL ABMySQL Server 5.1
You can use regedit to check which version you are using. It is specified at: HKEY_LOCAL_MACHINE/SOFTWARE/MySQL AB/MySQL Server 5.1.
Now try to build it again. I got this error:
buildtemp.win32-2.6Release_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:Python26Libdistutils, 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
>>>
Thank you Yun Fu. I found a different set of errors and wanted to post them. I’m running MySQL 5.0 and didn’t have to customize site.cfg in the same way. I have Visual Studion 9.0 installed and tried the build from cygwin. Here is the result. See the unresolved symbols:
$ python setup.py build
running build
running build_py
copying MySQLdbrelease.py -> buildlib.win32-2.6MySQLdb
running build_ext
building ‘_mysql’ extension
creating buildtemp.win32-2.6
creating buildtemp.win32-2.6Release
C:Program FilesMicrosoft Visual Studio 9.0VCBINcl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,3,’gamma’,1) -D_
_version__=1.2.3c1 “-IC:Program FilesMySQLMySQL Server 5.0include” -Ic:Python26include -Ic:Python26PC /Tc_mysql.c /Fobuildt
emp.win32-2.6Release_mysql.obj /Zl
_mysql.c
C:Program FilesMySQLMySQL Server 5.0includeconfig-win.h(163) : warning C4005: ‘SIZEOF_OFF_T’ : macro redefinition
c:python26includepyconfig.h(355) : see previous definition of ‘SIZEOF_OFF_T’
C:Program FilesMySQLMySQL Server 5.0includeconfig-win.h(313) : warning C4005: ‘HAVE_STDDEF_H’ : macro redefinition
c:python26includepyconfig.h(641) : see previous definition of ‘HAVE_STDDEF_H’
C:Program FilesMySQLMySQL Server 5.0includeconfig-win.h(321) : warning C4005: ‘HAVE_ISNAN’ : macro redefinition
c:python26includepyconfig.h(406) : see previous definition of ‘HAVE_ISNAN’
_mysql.c(1363) : warning C4018: ‘
F:devdownloadsMySQL-python-1.2.3c1MySQL-python-1.2.3c1>python setup.py build
running build
running build_py
copying MySQLdbrelease.py -> buildlib.win32-2.5MySQLdb
running build_ext
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing “-c mingw32″ to setup.py.
And of course, both cygwin gcc and mingw32 gcc builds didn’t work because of multiple definitions and undefined references.
Did you build python2.6 yourself with Visual Studio 9?
Hi Jonathan,
I did not build python 2.6 by myself. I installed it directly using the installer for windows. It is pythong 2.6 Windows version, not cygwin. I can see it is compiled by MSC v.1500 32 bit on win32.
thanks!
yun
Hi
I’m trying to the same procedures but with a difference in python (I’m using python 2.4.4)
I’m getting this error :
copying MySQLdbrelease.py -> buildlib.win32-2.4MySQLdb
running build_ext
building ‘_mysql’ extension
gcc -mno-cygwin -mdll -O -Wall -Dversion_info=(1,2,3,’gamma’,1) -D__version__=1.2.3c1 “-IC:optMySQLMySQL Server 5.1include” -IC:optPython24include -IC:o
ptPython24PC -c _mysql.c -o buildtemp.win32-2.4Release_mysql.o /Zl
error: command ‘gcc’ failed: No such file or directory
I removed MinGW from my path and added Visual C++ path
I don’t know where it is picking gcc from
Should I use some clause in setup.cfg file under [build_ext] item ?
Thanks
Hi Erico,
Sorry, I don’t know why it picks gcc in your case. Maybe MinGW left some environment variables. Maybe you should try to search for how to customize distutils to set c compiler. For me, if I do this, I can see it automatically picks MSVC
>>> from distutils.ccompiler import new_compiler
>>> c = new_compiler(None, None, None, None)
>>> c
< distutils.msvc9compiler.MSVCCompiler instance at 0x00BC25A8 >
thanks!
Yun
Thanks Yun
the problem was that I had configured distutils for plone3 and it had mingw32 referenced
now I got the same error from Jonathan.:
running build_ext
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing “-c mingw32″ to setup.py.
I installed python 2.4.4 with msi installer too
I have added Microsoft Visual Studio 9.0VCbin to PATH but it seems that it didn’t recognize it
Regards
Érico
Lots of people suggest compare pluses about become a freelance writer right before ordering custom essay papers in the writing corporation. And we will as get the fantastic texts connecting with this good post right there.
found this: http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe
installation works, haven’t tested the lib yet.
Pingback: Building MySQLdb for Python on Windows « Rational Pie
thanks alot…it worked fine…
Thank you! You saved me hours and hours of work. I would have been searching all day on how to solve these very cryptic errors.
@inhahe many thanks for the link, worked like charm!
Thank you very much, worked well with mysql 5.5.
Thanks! Saved my butt
This really saved my bacon!
I also had issues with an older version of the C++ compiler, that was fixed by installing Visual C++ 2008
Yun,
Thank you, thank you, thank you, thank you, thank you! I just can’t thank you enough for posting this. Worked like a charm.
Thanks, followed your instructions and it did the trick
check this…….
http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe
Words can barely express my gratitude for your posting. Without your help I would probably have given up after the first error message. Many thanks!
THANK YOU!!!! This has been kicking my ass all day. I’ve tried about 3 different solutions to fix the issue, but yours was the only one that worked.
If you ever come to Kansas City, drinks are on me!
THANK YOU!!!! It is great!!!!
Cheers from NYC,
Vladimir Garcia
Yun,
By mistake I have followed all your steps but without the Microsoft Visual C++ 2008 Express Edition installed…
I went into some of your errors, but at the end the “import MySQLdb” did not work!
So I have download and installed the Microsoft Visual C++ 2008 Express Edition and tried to build the setup.py again…
It failed baddly! but I’m not too sure how too proceed now. Any hint?
Hi Luiz,
Sorry to hear that. I just dumped all steps I have done there.
I can imagine If anything does not match exactly, it may fail.
I am sorry that I have no idea what’s the reason for your problem.
Sorry!
Yun
thank you very much!!!
Thank you for this walk through it is really great.
I also need to compile the pyd file in debug mode. Do you know what steps are required to do this?
I have been modifying the extra_compile_args in setup_windows.py. to
extra_compile_args = [ '/Zl', '/LDb' ]
but the compiled pyd is the same size. So it seems nothing happened.
There is a –debug option which can be specified when building.
After setting this I had to add the path to my own compiled python binaries in setup_windows.cfg to library_dirs
Thank you! Worked perfectly!
Thank you, this was giving me a headache!
Many thanks for posting this, Yun. I finally got pylzma to build on Windows XP under Python 2.6.
First, it was failing to find vcvarsall.bat even though I had just installed Visual Studio 10 and even after I made sure vcvarsall was in the PATH. I grepped for the error message, using TextPad and found msvc9compiler.py. Examining that file, I found it was looking for environment variable VS90COMNTOOLS. VS 10 had already added VS100COMNTOOLS, so I just copied its value to VS90COMNTOOLS.
Then I got the manifest building error, found your post, installed your fix, and it worked!
Pingback: Tweets that mention Install MySQL for Python (MySQLdb) on Windows -- Topsy.com
Amazing Tutorial.. Worked like a charm.. Great Job..Thanks a ton..
The above URL to the installer worked best for me. Thanks for the blog post though, thought I was going mad there.
Yun,
Thank you very much for posting this. I just installed this on Windows7 and so far it seems to be working.
Lisa
Actually I found this executable that easy install the mysql.
http://soemin.googlecode.com/files/MySQL-python-1.2.3c1.win32-py2.6.exe
I was having the same issues and was about to download the compiler. This saved my time!
Check it up!
Thx a lot !
it work very well for me.
Pingback: Instalar MySQL para Python (MySQLdb) em Windows « Blog do Victor Jabur
Hi Yun,
Thanks for all of your efforts. I tried all of your steps and tools except the MS Visual C++ 2008 Express edition, rather I have MS Visual Studio 2005. I got the following error:
C:softwareMySQL_FROM_PythonMySQL-python-1.2.3c1MySQL-python-1.2.3c1>setup.py
build
running build
running build_py
creating build
creating buildlib.win32-2.6
copying _mysql_exceptions.py -> buildlib.win32-2.6
creating buildlib.win32-2.6MySQLdb
copying MySQLdb__init__.py -> buildlib.win32-2.6MySQLdb
copying MySQLdbconverters.py -> buildlib.win32-2.6MySQLdb
copying MySQLdbconnections.py -> buildlib.win32-2.6MySQLdb
copying MySQLdbcursors.py -> buildlib.win32-2.6MySQLdb
copying MySQLdbrelease.py -> buildlib.win32-2.6MySQLdb
copying MySQLdbtimes.py -> buildlib.win32-2.6MySQLdb
creating buildlib.win32-2.6MySQLdbconstants
copying MySQLdbconstants__init__.py -> buildlib.win32-2.6MySQLdbconstants
copying MySQLdbconstantsCR.py -> buildlib.win32-2.6MySQLdbconstants
copying MySQLdbconstantsFIELD_TYPE.py -> buildlib.win32-2.6MySQLdbconstants
copying MySQLdbconstantsER.py -> buildlib.win32-2.6MySQLdbconstants
copying MySQLdbconstantsFLAG.py -> buildlib.win32-2.6MySQLdbconstants
copying MySQLdbconstantsREFRESH.py -> buildlib.win32-2.6MySQLdbconstants
copying MySQLdbconstantsCLIENT.py -> buildlib.win32-2.6MySQLdbconstants
running build_ext
building ‘_mysql’ extension
error: Unable to find vcvarsall.bat
I’d really appreciate if you can help me to resolve the issue.
Thanks,
Sanjoy
Pingback: » Ставим и запускаем Django+MySQL на Windows 7
Hello Yun,
Thank you, I managed to download setuptools and it started to build… untill that message:
“”"error: Python was built with Visual Studio version 7.1, and extensions need to be built with the same version of the compiler, but it isn’t installed.”"”
What should I do whith that? I installed Python 2.5 with the installer. I didn’t even know that it was build with Visual Studio 7.1! Should I add it in the path?
Awesome, worked perfect – you da man!
Hi.. My mysql database is located on a remote machine… So i dont have any local copy of mysql on my local machine.. i get the registry key error… (file not found)… But following your instructions, it requires to have a local copy of mysql… How do i install the mysqldb for database residing on another machine??? Please help and thanks in advance
Hello,
Thank you for your post.
I’m trying to install mysqldb with python 2.5, downloaded directly from sourceforge… So that means that it was precompiled (by Visual Studio 7.1, ie 2003).
So, when I try to do: “python setup.py install”, it says to me :
“”"building ‘_mysql’ extension
error: Python was built with Visual Studio version 7.1, and extensions need to be built with the same version of the compiler, but it isn’t installed.”"”
But what I don’t understand is that I have VS 2003 installed on my computer. I added it in my path… but I can’t go on the installation …
Any idea of what’s wrong?
Hi,
Thank very much. but is this message ok(i can ignore it ?):
D:serverpython26libsite-packagesmysql_python-1.2.3-py2.6-win32.egg_mysql.p
y:3: UserWarning: Module _mysql was already imported from D:serverpython26lib
site-packagesmysql_python-1.2.3-py2.6-win32.egg_mysql.pyc, but d:mysql-pytho
n-1.2.3 is being added to sys.path
??
Great Post for my website
Thanks! you help me a lot.
I LOVE You so much!
Thanks! I Spent a whole day trying to figure out what the heck was going on! I can hardly believe it finally works!
Thanks for the last suggestion. I went all the way up to the manifest thing, and was too tired to investigate.. But this manifest switch is just a bug in the msvc9compiler class or is something more specific to the MySQL module? That is, should I leave the switch there?
Thanks for the last suggestion. I went all the way up to the manifest thing, and was too tired to investigate further. But this missing manifest switch is just a bug in msvc9compiler or is something related to certain modules? Should I leave it there?
(n.b. if this gets double-posted, sorry… blame my company firewall)
Thanks for providing this info, Yun. It was really helpful.
Regards,
Seetharamu
Thanks for providing this info, Yun.
It was really helpful.
Regards,
Seetharamu
For some reason, this CAPTCHA is rejecting me…. I’ve tried about 10 times to post this comment, and it keeps saying
“That reCAPTCHA response was incorrect” or”duplicate comment.)
—–
Thanks very much for the suggestion. Saved some hours of work.
This /manifest switch, is it just a bug in msvc9compiler.py or is something that is required only occasionally?
thank you
Well Done ,,Good Job, …Thanks a lot dear ..it worked well ..
If you have no C compiler you can try compiled version. Try this:
http://stackoverflow.com/questions/2272786/python-issueunable-to-find-vcvarsall-bat
or this:
http://timvalenta.wordpress.com/2009/02/04/python-26-mysql/
It saved a lot of my time.
Thank you Yun
This is binary version for windows and py2.5: http://biohackers.net/wikiattach/Python2(2e)5/attachments/MySQL-python.exe-1.2.1_p2.win32-py2.5.exe
Thank you!!! Very Good Job.
Peace/salam/Hi:
install pymysql on windows in 4 steps, and use Mysql with python 2.6 and 2.7 and django :
http://web-eng-help.blogspot.com/2010/09/install-mysql-5-for-python-26-and.html
Good luck
great article, helped a lot, thanks
Thanks for posting this – it helped me greatly. Also works with Python 2.7.
Great! Finally managed to get it installed.
Worked like charm
Thanks a ton mate
Good post! Installed!
Great Job ! finally installed it.
Thank you very much. This works for me. Python 2.6 + mysql 5.1 under windows 7.
Works for Python 2.7 + mysql 5.1 on Vista.
Thank you Yun Fu!
You saved us many mandays
I followed your’s instruction, but:
running build
running build_py
copying MySQLdb
elease.py -> buildlib.win32-2.6MySQLdb
running build_ext
Traceback (most recent call last):
File C:Python26MySQL-python-1.2.3setup.py, line 18, in
setup(**metadata)
File C:Python26libdistutilscore.py, line 152, in setup
dist.run_commands()
File C:Python26libdistutilsdist.py, line 975, in run_commands
self.run_command(cmd)
File C:Python26libdistutilsdist.py, line 995, in run_command
cmd_obj.run()
File C:Python26libdistutilscommanduild.py, line 134, in run
self.run_command(cmd_name)
File C:Python26libdistutilscmd.py, line 333, in run_command
self.distribution.run_command(command)
File C:Python26libdistutilsdist.py, line 993, in run_command
cmd_obj = self.get_command_obj(command)
File C:Python26libdistutilsdist.py, line 869, in get_command_obj
klass = self.get_command_class(command)
File C:Python26libsite-packagessetuptoolsdist.py, line 395, in get_command_class
self.cmdclass[command] = cmdclass = ep.load()
File C:Python26libsite-packagespkg_resources.py, line 1954, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File C:Python26libsite-packagessetuptoolscommanduild_ext.py, line 1, in
from distutils.command.build_ext import build_ext as _du_build_ext
File C:Python26libdistutilscommanduild_ext.py, line 23, in
from distutils.msvccompiler import get_build_version
File C:Python26libdistutilsmsvccompiler.py, line 658, in
from distutils.msvc9compiler import MSVCCompiler
File C:Python26libdistutilsmsvc9compiler.py, line 627
SyntaxError: Non-ASCII character ‘’ in file C:Python26libdistutilsmsvc9compiler.py on line 627, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
What’s wrong ?
The 2008 visual c++ compiler has been replaced by visual studio 2010 express. It no longer seems to work so.. just download the binary you need.
http://webcache.googleusercontent.com/search?q=cache:1U6Y9Oc5uPMJ:sourceforge.net/projects/mysql-python/files/+python+2.5+MYSQL-python.exe-1.2.1_p2&hl=en&gl=us&strip=1
Thanks for this very helpful article. It is disappointing that the Windows build of mysql-python is so poorly maintained. You saved me a lot of time.
This is a great post, appreciate the detail! I have Python 2.5, will this work for this version or do I have to upgrade to 2.6? Thanks!
@Yun (and Ryszard) there is a typo in your text, so if one does copy paste your solution it goes in Ryszard’s error.
the appended line should be
ld_args.append(‘/MANIFEST’)
and not
ld_args.append(‘/MANIFEST’)
best regards and thank you for the solution!
sorry, I see the error doesn’t show… it’s about encoding, you have used a special character…
so, just type the line do not copy-paste
b
Hi,
I’m new to mysqldb and python. I’m having problem to compile mysqldb using python23.
It said that :
error: Python was built with version 6 of Visual Studio, and extensions need to be built with the same version of the compiler, but it isn’t installed.
I already install MS Visual C++ into my Windows Xp and its still show the same message. Any idea guys.
thanks
You’re great, thanks for this help. I’ve been developing in Python 2.6 and the thoughts of going back to Python 2.5 for MySQL to work was a nightmare. You’re GR8.
With love from NIGERIA.
Hi,
I have been able to install MySQLdb successfully. Could you please shed some light on how to install sitepackages in a network environment. Do i need to install sitepackages on each individual client machine or is there any way to do it in a central location which can be accessed by any script running on client machines.
Thanx for the help.
Cheers for that, was scrubbing around looking for some decent install notes.
Thanks very much for this!
Steve
Pingback: Install mysql for Python in Windows 7 | Questing Group
Precompiled binaries
Choose python version and it’ll install with no hassle.
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Pingback: Jeff Walker » So, maybe RPy2 is not a good idea
Pingback: Getting the MySQL-Python connector to work on Windows « Azitech
Thanks a lot
Tried with MySQL 5.5 but it is missing . Found a substitute but multiple linking errors. Decided to try MySQL 5.1.
Tried with MySQL 5.1 as directed but multiple linking errors:
C:Program Files (x86)Microsoft Visual Studio 9.0VCBINlink.exe /DLL /nologo
/INCREMENTAL:NO “/LIBPATH:C:Program FilesMySQLMySQL Server 5.1libopt” /LIBP
ATH:C:Python27libs /LIBPATH:C:Python27PCbuild kernel32.lib advapi32.lib wsoc
k32.lib mysqlclient.lib /EXPORT:init_mysql buildtemp.win32-2.7Release_mysql.o
bj /OUT:buildlib.win32-2.7_mysql.pyd /IMPLIB:buildtemp.win32-2.7Release_mys
ql.lib /MANIFESTFILE:buildtemp.win32-2.7Release_mysql.pyd.manifest
Creating library buildtemp.win32-2.7Release_mysql.lib and object buildtem
p.win32-2.7Release_mysql.exp
_mysql.obj : error LNK2019: unresolved external symbol _mysql_error@4 referenced
in function __mysql_Exception
_mysql.obj : error LNK2019: unresolved external symbol _mysql_errno@4 referenced
in function __mysql_Exception
_mysql.obj : error LNK2019: unresolved external symbol _mysql_server_init@12 ref
erenced in function __mysql_server_init
_mysql.obj : error LNK2019: unresolved external symbol _mysql_server_end@0 refer
enced in function __mysql_server_end
_mysql.obj : error LNK2019: unresolved external symbol _mysql_thread_safe@0 refe
renced in function __mysql_thread_safe
_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_fields@4 ref
erenced in function __mysql_ResultObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_num_fields@4 refer
enced in function __mysql_ResultObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_store_result@4 ref
erenced in function __mysql_ResultObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_use_result@4 refer
enced in function __mysql_ResultObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_real_connect@32 re
ferenced in function __mysql_ConnectionObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_ssl_set@24 referen
ced in function __mysql_ConnectionObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_options@12 referen
ced in function __mysql_ConnectionObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_init@4 referenced
in function __mysql_ConnectionObject_Initialize
_mysql.obj : error LNK2019: unresolved external symbol _mysql_close@4 referenced
in function __mysql_ConnectionObject_close
_mysql.obj : error LNK2019: unresolved external symbol _mysql_affected_rows@4 re
ferenced in function __mysql_ConnectionObject_affected_rows
_mysql.obj : error LNK2019: unresolved external symbol _mysql_debug@4 referenced
in function __mysql_debug
_mysql.obj : error LNK2019: unresolved external symbol _mysql_dump_debug_info@4
referenced in function __mysql_ConnectionObject_dump_debug_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_autocommit@8 refer
enced in function __mysql_ConnectionObject_autocommit
_mysql.obj : error LNK2019: unresolved external symbol _mysql_commit@4 reference
d in function __mysql_ConnectionObject_commit
_mysql.obj : error LNK2019: unresolved external symbol _mysql_rollback@4 referen
ced in function __mysql_ConnectionObject_rollback
_mysql.obj : error LNK2019: unresolved external symbol _mysql_next_result@4 refe
renced in function __mysql_ConnectionObject_next_result
_mysql.obj : error LNK2019: unresolved external symbol _mysql_set_server_option@
8 referenced in function __mysql_ConnectionObject_set_server_option
_mysql.obj : error LNK2019: unresolved external symbol _mysql_sqlstate@4 referen
ced in function __mysql_ConnectionObject_sqlstate
_mysql.obj : error LNK2019: unresolved external symbol _mysql_warning_count@4 re
ferenced in function __mysql_ConnectionObject_warning_count
_mysql.obj : error LNK2019: unresolved external symbol _mysql_escape_string@12 r
eferenced in function __mysql_escape_string
_mysql.obj : error LNK2019: unresolved external symbol _mysql_real_escape_string
@16 referenced in function __mysql_escape_string
_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_lengths@4 re
ferenced in function __mysql_row_to_tuple
_mysql.obj : error LNK2019: unresolved external symbol __imp__strncpy referenced
in function __mysql_row_to_dict
_mysql.obj : error LNK2019: unresolved external symbol __imp__strncat referenced
in function __mysql_row_to_dict
_mysql.obj : error LNK2019: unresolved external symbol _memset referenced in fun
ction __mysql_row_to_dict_old
_mysql.obj : error LNK2019: unresolved external symbol _mysql_fetch_row@4 refere
nced in function __mysql__fetch_row
_mysql.obj : error LNK2019: unresolved external symbol _mysql_num_rows@4 referen
ced in function __mysql_ResultObject_fetch_row
_mysql.obj : error LNK2019: unresolved external symbol _mysql_change_user@16 ref
erenced in function __mysql_ConnectionObject_change_user
_mysql.obj : error LNK2019: unresolved external symbol _mysql_character_set_name
@4 referenced in function __mysql_ConnectionObject_character_set_name
_mysql.obj : error LNK2019: unresolved external symbol _mysql_set_character_set@
8 referenced in function __mysql_ConnectionObject_set_character_set
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_character_set_
info@8 referenced in function __mysql_ConnectionObject_get_character_set_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_client_info@0
referenced in function __mysql_get_client_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_host_info@4 re
ferenced in function __mysql_ConnectionObject_get_host_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_proto_info@4 r
eferenced in function __mysql_ConnectionObject_get_proto_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_get_server_info@4
referenced in function __mysql_ConnectionObject_get_server_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_info@4 referenced
in function __mysql_ConnectionObject_info
_mysql.obj : error LNK2019: unresolved external symbol _mysql_insert_id@4 refere
nced in function __mysql_ConnectionObject_insert_id
_mysql.obj : error LNK2019: unresolved external symbol _mysql_kill@8 referenced
in function __mysql_ConnectionObject_kill
_mysql.obj : error LNK2019: unresolved external symbol _mysql_field_count@4 refe
renced in function __mysql_ConnectionObject_field_count
_mysql.obj : error LNK2019: unresolved external symbol _mysql_ping@4 referenced
in function __mysql_ConnectionObject_ping
_mysql.obj : error LNK2019: unresolved external symbol _mysql_real_query@12 refe
renced in function __mysql_ConnectionObject_query
_mysql.obj : error LNK2019: unresolved external symbol _mysql_select_db@8 refere
nced in function __mysql_ConnectionObject_select_db
_mysql.obj : error LNK2019: unresolved external symbol _mysql_shutdown@8 referen
ced in function __mysql_ConnectionObject_shutdown
_mysql.obj : error LNK2019: unresolved external symbol _mysql_stat@4 referenced
in function __mysql_ConnectionObject_stat
_mysql.obj : error LNK2019: unresolved external symbol _mysql_thread_id@4 refere
nced in function __mysql_ConnectionObject_thread_id
_mysql.obj : error LNK2019: unresolved external symbol __imp__sprintf referenced
in function __mysql_ConnectionObject_repr
_mysql.obj : error LNK2019: unresolved external symbol _mysql_data_seek@12 refer
enced in function __mysql_ResultObject_data_seek
_mysql.obj : error LNK2019: unresolved external symbol _mysql_row_seek@8 referen
ced in function __mysql_ResultObject_row_seek
_mysql.obj : error LNK2019: unresolved external symbol _mysql_row_tell@4 referen
ced in function __mysql_ResultObject_row_seek
_mysql.obj : error LNK2019: unresolved external symbol _mysql_free_result@4 refe
renced in function __mysql_ResultObject_dealloc
LINK : error LNK2001: unresolved external symbol __DllMainCRTStartup@12
buildlib.win32-2.7_mysql.pyd : fatal error LNK1120: 56 unresolved externals
error: command ‘”C:Program Files (x86)Microsoft Visual Studio 9.0VCBINlink.
exe”‘ failed with exit status 1120
@Christian bajada the installer at your link fails to find python 2.7 installed at default location (C:Python27) thus fails to install the precompiled binary.
Thankssssss.. dude,
you done a great job for us.
This help to me a lot and more.
But instead of found error:
build emp.win32-2.6Release_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
I got :
building ‘_mysql’ extension
error: Unable to find vcvarsall.bat
Otherwise, Thanks a lot again,
Hello webmaster I love your post ….
One easy way to install MySQLdb is to obtain exe from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
hi, I m trying to install mysqldb on windows with python 2.7, but getting error vcversall.bat not found.
Mysql version 6
please help…
I receive the following error:
‘IndentationError: unexpected indent’
with regards t o the change I made at “Then append the following line after the above line,”
see:
ld_args.append(‘/MANIFESTFILE:’ + temp_manifest)
ld_args.append(‘/MANIFEST’)
When I paste it in here i see an unexpected indent, but in notepadd++ the two lines are parallel.
Please advise…
@Priyanka
I had the same issue:
error: Unable to find vcvarsall.bat
I went ahead and made the change that followed:
“Then append the following line after the above line,”
And now I am faced with an indentation error mentioned above. But I am hopeful I am on the right track. I am using Python2.6
I figured out my indentation issue. I spaced over until they were aligned properly within notepad++. Theoretically I don’t understand what the difference is though i remember such talk of these differences at the university.
Anyhow, I am back to where I was prior to that step, which was with an error message not mentioned above.
error: Unable to find vcvarsall.bat
@Priyanka install Visual Studio 2008 Express edition, reboot, and you issue should be resolved. Fun stuff!
thanks for your job
it was of much help for this lazybug
Hola a todos
estoy instalando mysqldb para python en windows, pero no tengo instalado mysql de la manera formal, sino con wamp, que puedo hacer en ese caso?
Great Job! You save us tons time. The trick works with Visual Studio 2008 Express edition.
@Dan It works fine for me on multiple machines, and on the default location of C:Python27. I know it’s a dumb question but are you sure you chose the 2.7 version?
I love you man!!!! wow thanks!!!! YOur post save my head!
Pingback: Fix the problem while installing python packages. | read-think-act
Hi, I’m getting gcc status code 1: http://img638.imageshack.us/img638/275/gccfailedwithexitstatus.png – Can anyone help me?
Pingback: 在64位Windows 7上安装MySQLdb « CAFF
hi,
I followed your instruction and was able to run setup.py successfully. At the end, I got error: none.
However, when I tried to run import MySQLdb I’m getting the error: no module named _mysql
Any help is greatly appreciated.
Pingback: Instaladores de MySQLdb para Windows | Segaco
C:Python23MySQL-python-1.2.3>setup.py build
running build
running build_py
copying MySQLdbrelease.py -> buildlib.win32-2.3MySQLdb
running build_ext
building ‘_mysql’ extension
C:Program FilesMicrosoft Visual StudioVC98BINlink.exe /DLL /nologo /INCREME
NTAL:NO “/LIBPATH:C:Program FilesMySQLMySQL Server 5.5libopt” /LIBPATH:C:P
ython23libs /LIBPATH:C:Python23PCBuild kernel32.lib advapi32.lib wsock32.lib
mysqlclient.lib /EXPORT:init_mysql buildtemp.win32-2.3Release_mysql.obj /OUT:
buildlib.win32-2.3_mysql.pyd /IMPLIB:buildtemp.win32-2.3Release_mysql.lib
LINK : fatal error LNK1181: cannot open input file “mysqlclient.lib”
error: command ‘”C:Program FilesMicrosoft Visual StudioVC98BINlink.exe”‘ fa
iled with exit status 1181
I cannot figure out the reason for the error. I have got Microsoft Visual Studio 6, Python 2.3 and MySQL 5.5 installed in my system. I am trying to load MySQLdb
Nice post!
At this moment, for resolve this old warning, you can download and install python-mysqldb binaries from codegood.com
Hey ,
I followed your instructions but it does’nt help. First of all in windows 7 the SQL gets installed under Wow6432Node registry key. So i changed it in site.cfg but now there comes no error but am unable to import MySQLdb……
After two days trying to get this working I found the following steps seemed to work for me – read these in conjunction with the packaged README.
For Windows:
- download and install the following:
1. Python 2.7 http://www.python.org/
2. Setuptools http://pypi.python.org/pypi/setuptools
3. MinGW http://www.mingw.org/category/wiki/download
4. Mysql 5.1 http://www.mysql.com/downloads/
- Don’t worry about Zlib
- Don’t worry about OpenSSL
- comment out these lines in setup_windows.py
# XXX static doesn’t actually do anything on Windows
#if enabled(options, ‘embedded’):
# client = “mysqld”
#else:
# client = “mysqlclient”
- Add this line below the commented lines (this instructs the compiler to use the dynamic version of the mysql libraries – static will only work using the same compiler as mysql was compiled with.
client = “libmysql”
- Add the following to the PATH environment variable
C:MinGWbin;
- Change this line in site.cfg to the following
registry_key = SOFTWAREMySQL ABMySQL Server 5.1
- Run this command
python setup.py build –compile=mingw32
- Then Run this command
python setup.py install