#!/bin/bash
echo
"正在安裝依賴軟體包 請稍等......"
yum -y install gcc gcc-c++ make zlib-devel bzip2-devel openssl-devel sqlite-devel readline-devel libffi-devel wget &>/dev/null
if[ $? -eq 0 ]
;then
echo
"依賴軟體包安裝完成"
else
echo
"依賴安裝包安裝失敗 請檢查......"
"原始碼包解壓中請稍等......"
tar -xf python-3.7.6.tar.xz
echo
"原始碼包解壓完成"
echo
"進入解壓目錄"
cd .
/python-3.7.6
pwdecho
"已進入"
echo
"修改配置資訊請稍等......"
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
echo
"修改配置資訊完成"
echo
"開始編譯安裝請稍等......"
./configure --enable-shared &>/dev/null
make -j 1 &>/dev/null && make install &>/dev/null
if[ $? -eq 0 ]
;then
echo
"編譯安裝完成"
else
echo
"編譯安裝失敗請檢查"
fiecho
"配置環境請稍等......"
file="/etc/profile.d/python3_lib.sh"
echo
'export ld_library_path=$ld_library_path:/usr/local/lib' >$file
path="/usr/local/lib/"
file2="/etc/ld.so.conf.d/python3.conf"
echo
$path > $file2
if[ $? -eq 0 ]
;then
echo
"配置環境完成"
else
echo
"配置環境失敗請檢查"
fiecho
"環境資訊生效中請稍等......"
ldconfig
source /etc/profile
if[ $? -eq 0 ]
;then
echo
"環境資訊已完成"
else
echo
"環境資訊啟動失敗請檢查"
fiecho
"請用一下命令測試安裝:python3 -v 報[python 3.7.6]則安裝成功"
echo
"請用一下命令測試 pip3:pip3 -v 報[pip 20.0.2 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)]則成功"
在linux上安裝python3
我們原裝的centos上是有python2.7的,不建議刪除,可以做個python3共存的。python python 2.7.5 default,nov 20 2015,02 00 19 gcc 4.8.5 20150623 red hat 4.8.5 4 on linux2 which pyth...
在Linux上安裝Python3
一 安裝依賴環境 輸入命令 yum y install zlib devel bzip2 devel openssl devel ncurses devel sqlite devel readline devel tk devel gdbm devel db4 devel libpcap devel...
在Linux上安裝Python3
在linux上安裝python3 一 安裝依賴環境 yum y install zlib devel bzip2 devel openssl devel ncurses devel sqlite devel readline devel tk devel gdbm devel db4 devel l...