Skip to content
davispuh edited this page Aug 13, 2012 · 6 revisions

Requirements

  • Python 3 and headers (packages: python3 and python3-dev)
  • distribute
  • mysql_config utility along with MySQL headers (libmysqlclient-dev package)
  • compiler and linker
  • MySQL for Python 3 tarball

(MySQL server nor client aren't required, in case your MySQL server are on another machine)

Step by step

  1. Install Python 3 and also Python 3 headers sudo apt-get install python3 python3-dev
  2. check if python3 works
  3. download and install distribute. easiest way wget http://python-distribute.org/distribute_setup.py then python3 distribute_setup.py
  4. install libmysqlclient-dev package and it's dependencies. which will contain mysql_config and MySQL headers. Also as dependencies gcc will be installed. sudo apt-get install libmysqlclient-dev
  5. download MySQL for Python 3 tarball
  6. extract it
  7. and now finally install it with python3 setup.py install
  8. can test if it was successfully installed by opening python3 and import MySQLdb

Basic check

  1. install MySQL server sudo apt-get install mysql-server
  2. create test.py with contents from [Usage example](Usage example)
  3. edit settings (root password, etc) accordingly
  4. try it with python3 test.py

Note

apt-get is for Debian, Ubuntu distributions, if you've Fedora or CentOS then use yum. Different for others.

Clone this wiki locally