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
為什么要升級(jí)呢?因?yàn)橐渴鹨恍┸浖?,需要python3的支持?。?!不得不裝?。。?!

部署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安裝軟件時(shí)可能會(huì)有沖突。 # 一個(gè)比較好的解決方法是:進(jìn)入python3虛擬環(huán)境中安裝軟件。 [root@registry ~]# python3 -m venv py3 安裝虛擬環(huán)境,會(huì)在當(dāng)前目錄下生成一個(gè)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 # 有一個(gè)麻煩點(diǎn)的地方就是,每次在使用python3.9時(shí),都要先激活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)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
詳解Python數(shù)據(jù)可視化編程 - 詞云生成并保存(jieba+WordCloud)
這篇文章主要介紹了Python數(shù)據(jù)可視化編程 - 詞云生成并保存(jieba+WordCloud),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2019-03-03
健身房被搭訕?用python寫了個(gè)小米計(jì)時(shí)器助人為樂
今天教大家Python圖形界面開發(fā)的相關(guān)知識(shí),文章圍繞著如何實(shí)現(xiàn)一個(gè)小米手機(jī)上的秒表計(jì)時(shí)器功能展開,文中有非常詳細(xì)的代碼示例,需要的朋友可以參考下2021-06-06
python實(shí)現(xiàn)將兩個(gè)文件夾合并至另一個(gè)文件夾(制作數(shù)據(jù)集)
這篇文章主要介紹了python實(shí)現(xiàn)將兩個(gè)文件夾合并至另一個(gè)文件夾(制作數(shù)據(jù)集),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-04-04
pytorch實(shí)現(xiàn)CNN卷積神經(jīng)網(wǎng)絡(luò)
這篇文章主要為大家詳細(xì)介紹了pytorch實(shí)現(xiàn)CNN卷積神經(jīng)網(wǎng)絡(luò),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-02-02
解決django 向mysql中寫入中文字符出錯(cuò)的問(wèn)題
這篇文章主要介紹了解決django 向mysql中寫入中文字符出錯(cuò)的問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2020-05-05
python從sqlite讀取并顯示數(shù)據(jù)的方法
這篇文章主要介紹了python從sqlite讀取并顯示數(shù)據(jù)的方法,涉及Python操作SQLite數(shù)據(jù)庫(kù)的讀取及顯示相關(guān)技巧,需要的朋友可以參考下2015-05-05
pandas刪除重復(fù)數(shù)據(jù)簡(jiǎn)單方法
這篇文章主要給大家介紹了關(guān)于pandas刪除重復(fù)數(shù)據(jù)的簡(jiǎn)單方法,在數(shù)據(jù)處理過(guò)程中常常會(huì)遇到重復(fù)的問(wèn)題,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2023-07-07

