Centos7安装python3.7

安装依赖

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

下载以及解压

wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz
tar -xvJf  Python-3.7.6.tar.xz

编译安装

mkdir /usr/local/python3 #创建编译安装目录
cd Python-3.7.6
./configure --prefix=/usr/local/python3
make && make install

创建软链接

ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3

验证

python3 --version
pip3 -V

补充:
python 支持ssl 先尝试使用openssl-1.1.1c安装后失败。
使用libressl替代
下载
https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.8.0.tar.gz
./configure --prefix=/usr/local/ssllib
(如果/usr/local下有ssl 以及include/openssl 可以删掉 把ssllib下安装好的ssl 以及include/openssl 复制到对应的目录下)
进入Python安装目录
修改Modules/Setup Modules/Setup.dist 取消这几行的注释,并修改SSL=/usr/local/ssl 为SSL=/usr/local

# Socket module helper for socket(2)
_socket socketmodule.c

# 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.c \
        -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
        -L$(SSL)/lib -lssl -lcrypto

重新编译Python
./configure --prefix=/usr/local/python3
make 验证一下有没有错
make install

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

向往的生活Life

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值