日期:2014-05-16  浏览次数:20811 次

Linux配置python开发环境
由于之前需要用到第3方的扩展,但是centos5自带的python是2.4.3,这个版本很多第3放扩展工具无法支持,虽然后来手工升级到了2.7.2,但是还有有些动态文件无法自动创建链接成功,无奈之下只好选择了centos6,这个版本的自带的python是2.6.6,应该能被大部分的工具支持,在此记录下在rhl6环境下构建一个python开发环境的配置过程。
现在我想安装配置python、pyinstaller、fabric、pexpect、eclipse等工具。

0. 环境配置
[root@gtlionsdev ~]# hostname
gtlionsdev
[root@gtlionsdev ~]# cat /etc/issue
CentOS release 6.3 (Final)
Kernel \r on an \m

[root@gtlionsdev ~]# uname -a
Linux gtlionsdev 2.6.32-279.el6.i686 #1 SMP Fri Jun 22 10:59:55 UTC 2012 i686 i686 i386 GNU/Linux
[root@gtlionsdev ~]# python -V
Python 2.6.6
[root@gtlionsdev ~]# ldd /usr/bin/python
    linux-gate.so.1 =>  (0x00de4000)
    libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00b84000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00f8e000)
    libdl.so.2 => /lib/libdl.so.2 (0x00605000)
    libutil.so.1 => /lib/libutil.so.1 (0x00110000)
    libm.so.6 => /lib/libm.so.6 (0x005c6000)
    libc.so.6 => /lib/libc.so.6 (0x00179000)
    /lib/ld-linux.so.2 (0x00fab000)
[root@gtlionsdev ~]# file /usr/bin/python
/usr/bin/python: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped

1. 安装配置pyinstaller
首先需要安装下lsb-sdk,解压后直接rpm -Uivh *.rpm即可。
[root@gtlionsdev ~]# cd /opt
[root@gtlionsdev opt]# ls
pyinstaller-2.0.tar.bz2  rh
[root@gtlionsdev opt]# tar -jxf pyinstaller-2.0.tar.bz2;mv pyinstaller-2.0 pyinstaller;cd pyinstaller;cd source/
[root@gtlionsdev source]# python waf configure build install
Linux-32bit detected
Building LSB bootloader.
Checking for program gcc or cc           : /usr/bin/gcc
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib              : /usr/bin/ranlib
Checking for gcc                         : ok  
Checking for program python              : /usr/bin/python
Checking for Python version              : 2.6.6
Checking for library python2.6           : yes
Checking for program python2.6-config    : /usr/bin/python2.6-config
Checking for custom code                 : yes
Checking for program lsbcc               : not found
Checking for program /opt/lsb/bin/lsbcc  : not found
LSB (Linux Standard Base) tools >= 4.0 are required.
Try --no-lsb option if not interested in building LSB binary.
[root@gtlionsdev source]# python waf configure --no-lsb build install --如果没有lsb
Linux-32bit detected
Checking for program gcc or cc           : /usr/bin/gcc
Checking for program cpp                 : /usr/bin/cpp
Checking for program ar                  : /usr/bin/ar
Checking for program ranlib