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的支持?。。〔坏貌谎b啊?。?!
部署python3.9,并進入到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安裝軟件時可能會有沖突。 # 一個比較好的解決方法是:進入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 通過打碼平臺實現(xiàn)驗證碼的實現(xiàn)
這篇文章主要介紹了Python 通過打碼平臺實現(xiàn)驗證碼的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05全CPU并行處理Pandas操作Pandarallel更快處理數(shù)據(jù)
我們在處理數(shù)據(jù)時,通常小的數(shù)據(jù)對處理速度不敏感,但數(shù)據(jù)量一大,頓時會感覺數(shù)據(jù)處理效率不盡如人意,今天介紹的pandarallel就是一個簡單高效的Pandas并行工具,幾行代碼就可以提高數(shù)據(jù)處理效率,2024-01-01python獲取系統(tǒng)內(nèi)存占用信息的實例方法
在本篇文章里小編給大家整理的是關(guān)于python獲取系統(tǒng)內(nèi)存占用信息的實例方法,有需要的朋友們可以參考學(xué)習(xí)下。2020-07-07