6

I'm trying to use MySQL in Python. I have installed the MySQL adapter (MySQL-python-1.2.4b4.win32-py2.7) for Python, but when I try to import the MySQLdb module (import MySQLdb) with command prompt I receive the following output:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\MySQLdb\__init__.py", line 19, in <module>
import _mysql
ImportError: DLL load failed: %1 is not a valid Win32 application.

Would anybody know, what could be wrong?

3 Answers 3

9

You need to have a 32bit version of Python to use this adapter. Which version are you actually using ?

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. I had the 64bit version of Python.
2

I had problems installing the 64-bit version of MySQLdb on Windows via Pip, but if you want to continue using a 64-bit version of Python, rather than reverting to a 32-bit version, then you can install the compiled MySQLdb from the .whl file available from http://www.lfd.uci.edu/~gohlke/pythonlibs/

You will then want to install the .whl file as document in https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels

Comments

-1

when you setup the module ,be careful the version ,MySQL-python-1.2.3.win32-py2.7.exe and MySQL-python-1.2.4.win32-py2.7.exe ,only one of the 2 version is you need,try 2 times

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.