给Linux编译安装Python2.7,SSL与zlib模块

1、下载Python2.7

http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2

2、解压缩到当前目录

tar jxvf Python-2.7.tar.bz2

3、编辑Modules/Setup.dist

找到SSL和zlib模块,去掉某些注释,结果如下:

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
SSL=/usr/local/ssl
ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto

# Andrew Kuchling’s zlib module.
# This require zlib 1.1.3 (or later).
# See http://www.gzip.org/zlib/
zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz

4、安装OpenSSL

apt-get install libssl-dev

5、编译安装Python2.7

./configure
make && make install

给Linux编译安装Python2.7,SSL与zlib模块》有12个想法

  1. Test

    请教xiaoxia大神,如何编译python?
    我都是直接执行python xxx.py 这样的
    可是一个程序就占了一个会话
    有没有办法编译或者单独作为服务运行?

    回复
        1. Xiaoxia 文章作者

          你应该是先装了win7,后装kubuntu的吧。我试过这样做,需要重新激活win7,不知道是和引导有关还是和bios设置有关。

          回复
  2. yanwen

    How to uninstall python 2.7 after you install it? I just install it without the ssl and zlib modules (I am so sorry that my system has some problem,and then I only can type ABC instead of chinese.)

    回复
    1. Xiaoxia 文章作者

      你使用apt-get安装的么?还是编译的呢?

      如果是编译的话,试试make uninstall。
      如果是apt-get安装的,那就用apt-get卸载。

      回复
      1. yanwen

        输入法弄好了。。。。python在运行goagent脚本的时候 提示说没有zlib模块。。。。想添加上zlib模块 不知道怎么添加呢??

        呃。。我在安装的时候 不是make install 是 make altinstall 的。。。 这个是如何卸载阿?

        回复

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据