1

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

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

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

我在 python2.6.6 中安装了 mysql-connector 库,该库是使用 .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-connector 库,以便 python2.7 识别安装。

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

/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/还是我需要遵循其他/其他步骤。

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

4

1 回答 1

2

步骤是:

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`

这就是你需要做的所有事情。

于 2015-05-12T19:00:47.093 回答