Python在centos7.6上安裝python3.9的詳細(xì)教程(默認(rèn)python版本為2.7.5)
# 查看下centos7.6上的python版本 [root@registry ~]# cat /etc/redhat-release Linux release 7.6.1810 (Core) [root@registry ~]# python --version Python 2.7.5
為什么要升級呢?因為要部署一些軟件,需要python3的支持?。?!不得不裝?。。。?/p>

部署python3.9,并進(jìn)入到python3虛擬環(huán)境:
python3.9.0下載地址:https://www.python.org/ftp/python/3.9.0/
# 開啟yum的緩存功能,yum安裝軟件包是在線安裝,開啟緩存功能可以使得軟件包被下載到本地,方便后續(xù)使用。 [root@registry ~]# vim /etc/yum.conf keepcache=1 # 配置網(wǎng)絡(luò)yum源 [root@registry ~]# cd /etc/yum.repos.d/ [root@registry yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo # 安裝python3的依賴包 [root@registry ~]# yum install libffi-devel wget sqlite-devel xz gcc atuomake zlib-devel openssl-devel epel-release git -y # 編譯安裝python3.9.0 [root@registry ~]# cd /usr/local/src/ [root@registry src]# rz [root@registry src]# ll 總用量 17560 -rw-r--r-- 1 root root 17977808 9月 25 23:56 Python-3.9.0a1.tar.xz [root@registry src]# tar xf Python-3.9.0a1.tar.xz [root@registry src]# cd Python-3.9.0a1/ [root@registry Python-3.9.0a1]# ./configure && make -j 4 && make install # 可以看到python3.9已經(jīng)安裝上去了,但是默認(rèn)的還是2.7.5 [root@registry ~]# python --version Python 2.7.5 [root@registry ~]# python python python2.7 python3.9 python3-config python2 python3 python3.9-config # 由于centos7.6自帶的是python2.7.5,現(xiàn)在安裝python3.9.0,在使用python安裝軟件時可能會有沖突。 # 一個比較好的解決方法是:進(jìn)入python3虛擬環(huán)境中安裝軟件。 [root@registry ~]# python3 -m venv py3 安裝虛擬環(huán)境,會在當(dāng)前目錄下生成一個py3目錄 [root@registry ~]# ll py3 總用量 4 drwxr-xr-x 2 root root 193 10月 14 22:33 bin drwxr-xr-x 2 root root 6 10月 14 22:33 include drwxr-xr-x 3 root root 23 10月 14 22:33 lib lrwxrwxrwx 1 root root 3 10月 14 22:33 lib64 -> lib -rw-r--r-- 1 root root 75 10月 14 22:33 pyvenv.cfg [root@registry ~]# source /root/py3/bin/activate 激活py3虛擬環(huán)境 (py3) [root@registry ~]# python -V Python 3.9.0a1 # 有一個麻煩點的地方就是,每次在使用python3.9時,都要先激活py3虛擬環(huán)境。
總結(jié)
到此這篇關(guān)于Python在centos7.6上安裝python3.9(默認(rèn)python版本為2.7.5)的文章就介紹到這了,更多相關(guān)centos7.6安裝python3.9內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
詳解Python數(shù)據(jù)可視化編程 - 詞云生成并保存(jieba+WordCloud)
這篇文章主要介紹了Python數(shù)據(jù)可視化編程 - 詞云生成并保存(jieba+WordCloud),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03
python實現(xiàn)將兩個文件夾合并至另一個文件夾(制作數(shù)據(jù)集)
這篇文章主要介紹了python實現(xiàn)將兩個文件夾合并至另一個文件夾(制作數(shù)據(jù)集),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-04-04
pytorch實現(xiàn)CNN卷積神經(jīng)網(wǎng)絡(luò)
這篇文章主要為大家詳細(xì)介紹了pytorch實現(xiàn)CNN卷積神經(jīng)網(wǎng)絡(luò),文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-02-02
python從sqlite讀取并顯示數(shù)據(jù)的方法
這篇文章主要介紹了python從sqlite讀取并顯示數(shù)據(jù)的方法,涉及Python操作SQLite數(shù)據(jù)庫的讀取及顯示相關(guān)技巧,需要的朋友可以參考下2015-05-05

