Python 2.7 编译安装(Ubuntu 10.04)

安装编译环境

sudo apt-get install build-essential autoconf automake libreadline-dev libsqlite3-dev \
        libbz2-dev libssl-dev

编译安装

下载python2.7源代码、编译安装python2.7。

mkdir -p /data/packages/ \
&& cd /data/packages/ \
&& wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2 \
&& tar jxvf Python-2.7.2.tar.bz2 \
&& cd Python-2.7.2 \
&& ./configure --prefix=/usr --enable-unicode=ucs4 --with-dbmliborder=bdb \
--with-system-expat --with-system-ffi \
&& make && make altinstall

easy_install-2.7

cd /data/packages/ \
&& wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e \
&& tar zxvf setuptools-0.6c11.tar.gz \
&& cd setuptools-0.6c11 \
&& python2.7 setup.py install

安装其它python支持包

easy_install-2.7 -Z python-memcached MySQL_python sqlalchemy simplejson pyamf blinker Twisted pycrypto

passport、网关需要的包

# pycurl
apt-get install libcurl4-gnutls-dev
easy_install-2.7 -Z pycurl tornado pycrypto

# PIL Python Imaging Library
# 解决不能出验证码错误:ImportError: The _imagingft C module is not installed

sudo apt-get install libjpeg62-dev zlib1g-dev libfreetype6-dev

cd /data/packages/ \
&& wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz \
&& tar zxvf Imaging-1.1.7.tar.gz \
&& cd Imaging-1.1.7 \
&& python2.7 setup.py build_ext -i \
&& python2.7 selftest.py \
&& python2.7 setup.py install

# M2Crypto
apt-get install swig
easy_install-2.7 -Z M2Crypto