Centos7下源码安装Python3 及shell 脚本自动安装Python3的教程

时间:2021-05-22

一、源码安装

首先安装开发工具包

yum groupinstall -y "Development tools"

安装依赖软件包

yum -y install gcc gcc-c++ zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel libffi-devel wget

上Python 官网 找源码包的下载地址

wget https:///pypi/simple
然后我们执行如下代码安装软件 如果可以那就没有问题

pip3 install ipython

shell 脚本自动安装Python3

yum groupinstall -y "Development tools"#开发工具包touch /mnt/inst_pyth.logpositio_pyth=/mnt/inst_pyth.logecho "开始安装依赖包-----"yum -y install gcc gcc-c++ zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel libffi-devel wget tar >> $positio_pyth#依赖包rpm -q gcc gcc-c++ zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel libffi-devel wget tar >> $positio_pythif [ $? -ne 0 ];then exitfiecho "开始下载python安装包,请耐心等待------"wget https://www.python.org/ftp/python/3.7.6/Python-3.7.6.tar.xz -O /usr/local/Python-3.7.6.tar.xz#下载安装包if [ $? -ne 0 ];then exitficd /usr/local/tar xf Python-3.7.6.tar.xz >> $positio_pythcd Python-3.7.6sed -ri 's/^#(readline)/\1/' /usr/local/Python-3.7.6/Modules/Setup.distsed -ri 's/^#(SSL=)/\1/' /usr/local/Python-3.7.6/Modules/Setup.distsed -ri 's/^#(_ssl)/\1/' /usr/local/Python-3.7.6/Modules/Setup.distsed -ri 's/^#([ \t]*-DUSE)/\1/' /usr/local/Python-3.7.6/Modules/Setup.distsed -ri 's/^#([ \t]*-L\$\(SSL\))/\1/' /usr/local/Python-3.7.6/Modules/Setup.dist# 到配置文件里打开这几行的注释./configure --enable-shardea=`cat /proc/cpuinfo|awk '/cpu cores/ {print $NF}'`make -j $a && make install >> $positio_pyth#j 指定cpu核数touch /etc/profile.d/python3_lib.shecho "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib" > /etc/profile.d/python3_lib.shtouch /etc/ld.so.conf.d/python3.confecho "/usr/local/lib" > /etc/ld.so.conf.d/python3.confldconfig#使添加的内容生效source /etc/profile#生效环境变量pip3 -Vif [ $? -eq 0 ];then echo "安装成功"else echo "安装失败"fi

到此这篇关于Centos7下源码安装Python3 shell 脚本自动安装Python3的文章就介绍到这了,更多相关Centos7安装Python3 内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章