Linux下原码安装 python-3.6.6

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下原码安装 python-3.6.6相关的知识,希望对你有一定的参考价值。

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 ‘[email protected]^#(_ssl)@\[email protected]‘ Modules/Setup.dist
# sed -ri ‘[email protected]^#([ \t]*-DUSE)@\[email protected]‘ Modules/Setup.dist
# sed -ri ‘[email protected]^#([ \t]*-L\$\(SSL\))@\[email protected]‘ 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

以上是关于Linux下原码安装 python-3.6.6的主要内容,如果未能解决你的问题,请参考以下文章

原码反码补码

Linux 安装Python3

python安装Windows上安装和创建python开发环境

Centos 安装python3

centos 7 python3.6.6的编译安装

docker -安装Python 脚本