zoukankan      html  css  js  c++  java
  • New method for installing Python 2.6.4 (with mysqlpython) on CentOS 5.5

    New method for installing Python 2.6.4 (with mysql-python) on CentOS 5.5 | blog.milford.io

    New method for installing Python 2.6.4 (with mysql-python) on CentOS 5.5

    So I wrote in an earlier post about alt-installing Python 2.6 from source on CentOS, which was easy enough.  But, this made it more difficult to maintain and deploy as well as add modules.  So, I was lucky enough to come across a nice little yum repository hosted by Rizwan Kassim (Geekymedia.com) that contained an RPM that would do the alt-install work for me :)

    I’m aware that EPEL has a Python 2.6 package, but the Geekymedia RPMs have a whole flurry of modules you can add as well as an RPM for setuptools which will make your life immeasurably easier when running Python 2.4 and 2.6 side-by-side for installing python packages.

    The only problems with the Geekymedia RPMs are that the binary packages are all 32-bit (I’m running servers here folks!) and I was unable to get the MySQL-python26 one to work right for me.

    So, let’s get down to business.

     

    First I wanted to get rid of the existing python26 alt-install and EPEL rpms I installed.  This is only needed if you followed my last tutorial.

    rpm -qa | grep python26 | rpm -e --nodeps $(xargs)
    rm -rf /usr/local/lib/python2.6
    rm -rf /usr/local/include/python2.6
    rm -rf /usr/local/lib/libpython2.6.a
    rm -rf /usr/bin/python2.6
    rm -rf /usr/include/python2.6
    rm -rf /usr/lib/python2.6
    rm -rf /usr/lib64/libpython2.6.so.1.0
    rm -rf /usr/lib64/python2.6
    rm -rf /usr/local/bin/python2.6
    rm -rf /usr/local/bin/python2.6-config
    rm -rf /etc/rpm/macros.python26
    rm -rf /root/MySQL-python26-1.2.3-0.3.c1.src.rpm
    rm -rf /usr/bin/python26
    rm -rf /usr/share/doc/python26-2.6.5
    rm -rf /usr/share/doc/python26-libs-2.6.5
    rm -rf /usr/src/Python-2.6.4/PC/os2emx/python26.def

    Now, let us get started in earnest.  The next few steps are for compiling and building our own distributable RPMs and only need to be done once, after this you can use the already built RPMs everywhere.

    Install stuff for building the RPMs:

    yum -y install rpm-build gcc-c++

    Install the dependancies for building the RPMs from source.

    yum -y install readline-devel openssl-devel gmp-devel ncurses-devel \
    gdbm-devel expat-devel libGL-devel libX11-devel tcl-devel tk-devel \
    tix-devel sqlite-devel db4-devel

    Grab the Geekymedia src rpms.

    rpm -Uvh http://mirrors.geekymedia.com/centos/python26-2.6-geekymedia1.src.rpm
    rpm -Uvh http://mirrors.geekymedia.com/centos/python26-setuptools-0.6c9-5.src.rpm

    Build and install the alt-installed Python 2.6 RPMs

    rpmbuild -bb /usr/src/redhat/SPECS/python.spec
    rpm -Uvh /usr/src/redhat/RPMS/x86_64/python26-2.6-geekymedia1.x86_64.rpm
    rpm -Uvh /usr/src/redhat/RPMS/x86_64/python26-libs-2.6-geekymedia1.x86_64.rpm
    rpm -Uvh /usr/src/redhat/RPMS/x86_64/python26-tools-2.6-geekymedia1.x86_64.rpm
    rpm -Uvh /usr/src/redhat/RPMS/x86_64/python26-devel-2.6-geekymedia1.x86_64.rpm
    rpm -Uvh /usr/src/redhat/RPMS/x86_64/python26-test-2.6-geekymedia1.x86_64.rpm
    rpm -Uvh /usr/src/redhat/RPMS/x86_64/tkinter26-2.6-geekymedia1.x86_64.rpm

    Build and install the alt-installed setuptools:

    rpmbuild -bb /usr/src/redhat/SPECS/python26-setuptools.spec
    rpm -Uvh /usr/src/redhat/RPMS/noarch/python26-setuptools-0.6c9-5.noarch.rpm  

    For future machines you can dump all those RPMs in your own repo or on an nfs share and install them.  You’ll only need to do something like:

    yum -y install tk tix
    rpm -Uvh /path/to/rpms/python26/*.rpm

    And finally, we can install the PyPI MySQL-python package (you may need to login and out again to refresh your PYTHONPATH):

    yum -y mysql-devel
    curl http://superb-sea2.dl.sourceforge.net/project/mysql-python/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz | tar zxv
    cd MySQL-python-1.2.3
    python26 setup.py build
    python26 setup.py install

    Note how I called the script explicitly using the following python binary: /usr/bin/python26

    Now we’re good to give it the old test thus:

    python26 -c "import MySQLdb"

    If it doesn’t spit out an error, you’re aces. Bazinga!

  • 相关阅读:
    微服务迁移记(二):注册中心(consul搭建)
    微服务迁移记(一):技术架构
    小程序入坑记录
    不思量,自难忘:我的10年程序生涯
    your password has expired.to log in you must change it
    Javascript中 a.href 和 a.getAttribute('href') 结果不完全一致
    PHP不使用递归的无限级分类
    百度移动搜索自动转码太坑爹,JS跳转地址会被抓取
    iScroll 下 a 标签失效
    浏览器的云加速可能导致IP统计异常
  • 原文地址:https://www.cnblogs.com/lexus/p/2368683.html
Copyright © 2011-2022 走看看