centos離線安裝python3

方法一

首先找到一臺(tái)有網(wǎng)絡(luò)的相同環(huán)境電腦
如果是centos6,因?yàn)閲鴥?nèi)yum鏡像源已經(jīng)將其遷移到vault需要修改yum源為清華源vault源

修改鏡像源

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the 
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base  
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#released updates 
[updates]
name=CentOS-$releasever - Updates 
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras  
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus  
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib  
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

根據(jù)系統(tǒng)版本修改$releasever值

yum clean all && yum makecache
yum install yum-plugin-downloadonly -y
yum install  --downloadonly --downloaddir=./pydep/  bzip2-devel gcc gcc-c++ autoconf automake make zlib zlib-devel -y 

以上安裝的是centos6.5的依賴具體的依賴需要根據(jù)不同的環(huán)境添加
下載python
http://npm.taobao.org/mirrors/python/

安裝python依賴

rpm -ivh pydep/*
rpm -Uvh pydep/*

安裝python

tar -xzvf Python-3.6.0.tgz
cd ./Python-3.6.0
./configure --prefix=/usr/local/python36 
make && make install
ln -s /usr/local/python36/bin/python3.6 /usr/bin/python36

將python3軟連接到了python36
后面運(yùn)行python3用python36這個(gè)命令

方法二

直接安裝miniConda,無需安裝依賴
前往清華下載
https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh

sh Miniconda3-latest-Linux-x86_64.sh 

根據(jù)命令提示一步步安裝
運(yùn)行時(shí)如果指定了安裝路徑則需要記下來
默認(rèn)是/root/miniconda3

添加環(huán)境變量

sudo vi /etc/profile

最后一行加上

export PATH=$PATH:/剛剛指定的路徑/bin

保存后退出

source /etc/profile
source activate 

然后可以用conda創(chuàng)建虛擬環(huán)境愉快的玩耍了

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容