Skip to content Skip to sidebar Skip to footer

How To Install Mysqldb With Python 3.2

I'm trying to connect to mySQL with python. From what I understand you need to have MySQLdb which is some python connector module. My first problem was not having the right version

Solution 1:

Please note that you have to have curl installed. You can grab it from here. Assuming python.exe command starts python3 on your machine.

Steps:

  1. Download distribute_setup.py from python-distribute.org/distribute_setup.py‎ to upgrade setuptools.
  2. Execute the following command to upgrade setuptools for your local python3:

    python.exe distribute_setup.py

  3. Download and install the pymysql driver:

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

  4. Download and install MySQLdb driver for python3

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

  5. To check open python interpreter via python.exe command and execute:

    import pymysql import MySQLdb

If everything went ok - then both lines should not fail.

Solution 2:

I couldn't get MySQLdb to work with Python 3 either, so I installed the MySQL/Connector module. It's been workin' like a charm & it was a simple install. I was a complete Python newbie at the time, so unless I'm a genius then it's pretty easy to install for anyone.

Solution 3:

After further googling I don't think that using mysqldb or whatever is the best solution. I found this page: http://wiki.python.org/moin/MySQL I decided to give the mysql connector/python a try. It seems pretty straightforward with no crazy installs.

Post a Comment for "How To Install Mysqldb With Python 3.2"