MySQL Connector/Python Developer Guide  /  Connector/Python Installation  /  Installing Connector/Python from a Source Distribution

4.3 Installing Connector/Python from a Source Distribution

Connector/Python source distributions are platform independent and can be used on any platform. Source distributions are packaged in two formats:

  • Zip archive format (.zip file)

  • Compressed tar archive format (.tar.gz file)

Either packaging format can be used on any platform, but Zip archives are more commonly used on Windows systems and tar archives on Unix and Unix-like systems.

Prerequisites for Compiling Connector/Python with the C Extension

As of Connector/Python 2.1.1, source distributions include the C Extension that interfaces with the MySQL C client library. You can build the distribution with or without support for this extension. To build Connector/Python with support for the C Extension, you must satisfy the following prerequisites.

  • Prerequisites for Windows systems:

    • Correct version of Visual Studio: VS 2009 for Python 2.7, VS 2010 for Python 3.3

    • Python development files

    • MySQL Connector/C or MySQL Server installed, including development files

  • Prerequisites for Unix and Unix-like systems:

    • A C/C++ compiler, such as gcc

    • Python development files

    • MySQL Connector/C or MySQL Server installed, including development files

You must install Connector/C or MySQL Server if it is not already present on your system. To obtain either product, visit the MySQL download site.

For certain platforms, MySQL development files are provided in separate packages. This is true for RPM and Debian packages, for example.

Installing Connector/Python from Source on Microsoft Windows

A Connector/Python Zip archive (.zip file) is available from the Connector/Python download site (see Section 4.1, “Obtaining Connector/Python”).

To install Connector/Python from a Zip archive, download the latest version and follow these steps:

  1. Unpack the Zip archive in the intended installation directory (for example, C:\mysql-connector\) using WinZip or another tool that can read .zip files.

  2. Start a console window and change location to the folder where you unpacked the Zip archive:

    shell> cd C:\mysql-connector\
  3. Inside the Connector/Python folder, perform the installation using this command:

    shell> python setup.py install

    To include the C Extension (available as of Connector/Python 2.1.1), use this command instead:

    shell> python setup.py install --with-mysql-capi="path_name"

    The argument to --with-mysql-capi is the path to the installation directory of either MySQL Connector/C or MySQL Server.

To see all options and commands supported by setup.py, use this command:

shell> python setup.py --help

Installing Connector/Python from Source on Unix and Unix-Like Systems

For Unix and Unix-like systems such as Linux, Solaris, OS X, and FreeBSD, a Connector/Python tar archive (.tar.gz file) is available from the Connector/Python download site (see Section 4.1, “Obtaining Connector/Python”).

To install Connector/Python from a tar archive, download the latest version (denoted here as VER), and execute these commands:

shell> tar xzf mysql-connector-python-VER.tar.gz
shell> cd mysql-connector-python-VER
shell> sudo python setup.py install

To include the C Extension (available as of Connector/Python 2.1.1), use this command instead:

shell> sudo python setup.py install --with-mysql-capi=value

The argument to --with-mysql-capi is the path to the installation directory of either MySQL Connector/C or MySQL Server, or the path to the mysql_config command.

To see all options and commands supported by setup.py, use this command:

shell> python setup.py --help

User Comments
Sign Up Login You must be logged in to post a comment.