How to install MySQLdb with python 3.2

I am trying to connect to mySQL using python. As far as I understand, you should have MySQLdb, which is some python connector module. My first problem was not the correct version of mySQLdb. Here can be found here . Then I have to open a command prompt window and go to the path to the file I just downloaded (after unzipping) and type python setup.py build . Then it gave me an error saying that I needed to download the installation tools. The installation tools seem to have been discontinued after python 2.6 or 7. Now we should use the distribution kit that I found here as a replacement. I did it, and now when I try to make my call, he spits out

 Traceback (most recent call last): File "setup.py", line 13, in <module> from setup_windows import get_config File "C:\Program Files\MySQL\MySQL-python-1.2.3\setup_windows.py", line 46 print """You shouldn't be running this directly; it is used by setip.py.""" Syntax Error: invalid syntax 

I need someone to hold my hand and guide me through how to get this setting. I spent 6 hours at Google trying to figure this out. (I read in several places that this is a complex setup, but worth it. I hope they are right.)

+4
source share
3 answers

After further searching on Google, I don't think using mysqldb or anything else is the best solution. I found this page: http://wiki.python.org/moin/MySQL I decided to try trying mysql connector / python. It looks pretty simple without crazy setups.

0
source

Please note that you must install curl . You can get it from here .
Assuming the python.exe command runs python3 on your computer.

Steps:

  • Download distribute_setup.py from python-distribute.org/distribute_setup.py to update setuptools.
  • Run the following command to update setuptools for your local python3:

    python.exe distribute_setup.py

  • Download and install pymysql driver:

    curl -L https://github.com/PyMySQL/PyMySQL/tarball/pymysql-0.6 | tar xz
    cd PyMySQL-PyMySQL-7c86923 /
    sudo python3 setup.py install

  • Download and install MySQLdb driver for python3

    git clone https://github.com/davispuh/MySQL-for-Python-3.git
    cd MySQL-for-Python-3 /
    Install python3 setup.py

  • To test the open python interpreter using the python.exe command and run:

    import pymysql
    import MySQLdb

If everything went fine, then both lines should not fail.

+4
source

I could not get MySQLdb to work with Python 3, so I installed the MySQL / Connector module . It worked like a charm, and it was an easy installation. I was a complete Python newbie at the time, so if I'm not a genius then it is easy to install for anyone.

+1
source

All Articles