当前位置: 代码迷 >> 综合 >> centos5.6下安装python2.6及相关环境
  详细解决方案

centos5.6下安装python2.6及相关环境

热度:22   发布时间:2023-12-10 16:00:58.0

安装python2.6


  安装开发包,以便编译python的modules

  1. yum install openssl-devel, bzip2-devel, readline-devel, gdbm-devel, sqlite-devel, ncurses-devel, tk-devel

  下载phtyon2.6源码包Python-2.6.7.tgz:

  1. cd /usr/local/src
  2. wget http://www.python.org/ftp/python/2.6.7/Python-2.6.7.tgz

  解压缩及编译配置:

  1. tar zxvf Python-2.6.7.tgz
  2. cd Python-2.6.7
  3. ./configure --prefix=/usr/local/python2.6

  修改Python的Modules配置:

  1. vim Modules/Setup

  查找zlib zlibmodule.c,将找到如下一行:

  1. #zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz

  将前边的#号去掉,然后编译安装:

  1. make
  2. make install

  编辑环境变量

  1. vim ~/.bashrc

  在最后添加

  1. export PATH=$PATH:/usr/local/python2.6/bin

  下载并安装setuptools

  1. cd ..
  2. wget http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
  3. sh setuptools-0.6c11-py2.6.egg


安装python2.6会影响到yum工具,需要修改

vim /usr/bin/yum

第一行,改为python2.4位置


安装mysql-devel

  yum install mysql-devel


安装zlib*

  yum install zlib*


安装mysqldb模块

  

  python2.6 setup.py build

  python2.6 setup.py install