我有一个linux CENTOS 6.6服务器,默认安装了python2.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目录中的__init__.pyc
和__init__.pyo
文件具有特定于python2.6.6的路径,并且可能在安装过程中构建
答案 0 :(得分: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`
这就是你需要做的一切。