在 python 的侧面安装中安装 mysql-连接器(除了默认的 python 安装)

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

我有一台 linux CENTOS 6.6 服务器,默认安装了 python2.6.6。

我需要一个 python 版本的 2.7,但是 CENTOS 6.6 需要它的默认 python2.6.6 安装,因为各种系统原因(yum 取决于 2.6.6)。

因此,我在单独的位置 (/usr/local/lib/python2.7/) 安装了 python 2.7。现在我正在尝试安装我在 2.7 版本的 python2.6.6 中使用的所有软件包。

我在 python2.6.6 中安装了 mysql-连接器库,它是使用来自以下位置的 .rpm 文件安装的:

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. 

我不确定如何安装 mysql-连接器库,以便 python2.7 识别安装。

我注意到 mysql-connector 库在 python2.6.6。 (默认)安装位于此处:

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

解决方案是简单地将 mysql 目录和 egg-info 文件复制+重命名到 /usr/local/lib/python2.7/site-packages/ 还是有 additional/other 我需要遵循的步骤。

我不确定副本是否能解决这个问题,因为 mysql 目录有 __init__.pyc__init__.pyo 文件,这些文件的路径特定于 python2。 6.6 并且可能在安装过​​程中构建。

步骤是:

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`

这就是您需要做的全部。