centos7下安裝python3總步驟分三步: 一、依賴解決: 1.安裝依賴包: yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make ...
centos7下安裝python3總步驟分三步: 一、依賴解決: 1.安裝依賴包: yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make lrzsz libffi-devel -y 二、下載解壓安裝python3: 2.下載python3 wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tar.xz 3.解壓python安裝包 tar -xf Python-3.7.3.tar.xz 4.編譯安裝python 1)cd 到解壓出來的Python-3.7.3 2)編譯安裝 ./configure prefix=/usr/local/python3 && make && make install 5.備份python、pip 1)進入python2、pip所在的目錄 cd /usr/bin mv python python.bak mv pip pip.bak 三、環境檢查和配置: 6.製作python3的軟連接 ln -s /usr/local/python3/bin/python3 /usr/bin/python ln -s /usr/local/python3/bin/pip3 /usr/bin/pip 7.修改linux系統中需要python2支持的文件內容 1)vi /usr/bin/yum 把第一行:#! /usr/bin/python修改為#! /usr/bin/python2 2)vi /usr/libexec/urlgrabber-ext-down 把第一行的#! /usr/bin/python 修改為#! /usr/bin/python2 8.測試python3 python -V #版本3 大寫的V pip -V #pip3版本 python2 -V #版本2 pip2 -V #pip2版本