Linux下原码安装 python-3.

发布时间:2019-07-23 09:41:52编辑:auto阅读(1222)

    Linux下原码安装 python-3.6.6

    • 下载

      # wget https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
    • 安装依赖包

      # yum -y install zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel gcc
    • 解压并进入到解压目录
    # tar xvf Python-3.6.6.tgz
    # cd Python-3.6.6/
    
    • 修改 Modules/Setup.dist

    167 #readline readline.c -lreadline –ltermcap
    210 #SSL=/usr/local/ssl
    212 #_ssl _ssl.c \
    214 # -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
    216 # -L$(SSL)/lib -lssl –lcrypto
    将以上几行的#号去掉

    # sed -ri 's/^#readline/readline/' Modules/Setup.dist
    # sed -ri 's/^#(SSL=)/\1/' Modules/Setup.dist
    # sed -ri 's@^#(_ssl)@\1@' Modules/Setup.dist
    # sed -ri 's@^#([ \t]*-DUSE)@\1@' Modules/Setup.dist
    # sed -ri 's@^#([ \t]*-L\$\(SSL\))@\1@' Modules/Setup.dist
    • 编译安装

      # ./configure --enable-shared
      # make && make install
    • 查看是否安装成功

      # python3

      python3: error while loading shared libraries: libpython3.6m.so.1.0: cannot open shared object file: No such file or directory
      出现以上报错

    • 解决以上问题
    # find /usr/local/lib/ -name "libpython3.6m.so.1.0"
    /usr/local/lib/libpython3.6m.so.1.0
    # vim /etc/profile.d/python3_lib.sh
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
    # source /etc/profile
    
    • 再次检查安装是否成功
    # python3
    >>> exit()
    # pip3 –V
    

关键字