Search code examples
pythonmysqlmysql-connectormysql-connector-python

install mysql-connector in side installation of python (in addition to default python install)


I have a linux CENTOS 6.6 server that has python2.6.6 installed by default.

I need a python version of 2.7 but CENTOS 6.6 NEEDS its default python2.6.6 install present for various system reasons (yum depends on 2.6.6).

As such, I installed python 2.7 in a separate location (/usr/local/lib/python2.7/). Now I am trying to install all the packages that I was using in python2.6.6 in the 2.7 version.

I have mysql-connector library installed in python2.6.6, which was installed using the .rpm file from:

https://dev.mysql.com/doc/connector-python/en/connector-python-installation-binary.html

Installing Connector/Python on Linux Using an RPM Package

Connector/Python Linux RPM packages (.rpm files) are available from the Connector/Python download site (see Section 4.1, “Obtaining Connector/Python”).

To install a Connector/Python RPM package (denoted here as PACKAGE.rpm), use this command:

shell> rpm -i PACKAGE.rpm

To install the C Extension (available as of Connector/Python 2.1.1), install the corresponding package with “cext” in the package name.

RPM provides a feature to verify the integrity and authenticity of packages before installing them. To learn more, see Verifying Package Integrity Using MD5 Checksums or GnuPG. 

I'm not sure how I can install the mysql-connector library such that python2.7 recognizes the install.

I noticed that mysql-connector library in the python2.6.6. (default) install is located here:

/usr/lib/python2.6/site-packages/mysql/
/usr/lib/python2.6/site-packages/mysql_connector_python-1.1.5-py2.6.egg-info

Is the solution simply to copy+rename the mysql directory and egg-info file over to /usr/local/lib/python2.7/site-packages/ or are there additional/other steps that I need to follow.

I'm not certain a copy would solve this problem as the mysql directory has __init__.pyc and __init__.pyo files that have paths that are specific to python2.6.6 and likely built during the installation process.


Solution

  • Steps are:

    1) re-download the package from `https://dev.mysql.com`
    2) untar the `mysql-connector-python-1.1.4.tar.gz`
    3) cd into mysql-connector-python-1.1.4
    4) envoke `python2.7 setup.py install`
    

    Thats all you need to do.