10-flask部落格專案
centos7 編譯安裝python3.7.1
安裝步驟
centos7自帶python2,由於執行yum需要python2,所以即使安裝了python3也不能刪除python2
1.安裝依賴包
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
2.下載自己需要的python版本,例如python3.7.1,下載要花費一段時間,要耐心等待
yum -y install wget
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
3.新建一個資料夾存放python3
mkdir /usr/local/python3
4.把安裝包移動到該新建資料夾下,解壓安裝包,安裝python3,依次執行以下命令,花費時間較長,耐心等待
mv Python-3.7.1.tar.xz /usr/local/python3
tar -xvJf Python-3.7.1.tar.xz
cd Python-3.7.1
./configure --prefix=/usr/local/python3
make
make install
5.建立軟連線
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
6.此時python3已經裝好,在命令列中輸入python3測試
7.修改yum配置檔案,python2與python3共存
vi /usr/bin/yum
把#! /usr/bin/python修改為#! /usr/bin/python2(配置檔案第一行)
同理
vi /usr/libexec/urlgrabber-ext-down
把檔案裡面的#! /usr/bin/python 也修改為#! /usr/bin/python2
此時完成python3安裝,且實現與python2共存,保持yum命令可用
下面是Ubuntu配置:
sudo apt-get install gcc
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev
安裝好之後將一些檔案開頭改成系統的python版本,避免衝突
vim /usr/lib/command-not-found
vim /usr/bin/gnome-terminal
安裝過程詳解
centos7自帶python2,由於執行yum需要python2,所以即使安裝了python3也不能刪除python2
1.安裝依賴包
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
開發工具包組沒安裝上,下面的包都裝上了
2.下載自己需要的python版本,例如python3.7.1,下載要花費一段時間,要耐心等待
yum -y install wget
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
3.新建一個資料夾存放python3
mkdir /usr/local/python3
4.把安裝包移動到該新建資料夾下,解壓安裝包,安裝python3,依次執行以下命令,花費時間較長,耐心等待
mv Python-3.7.1.tar.xz /usr/local/python3
cd /usr/local/python3
tar -xJf Python-3.7.1.tar.xz
cd Python-3.7.1
./configure --prefix=/usr/local/python3
make
make install
5.建立軟連線
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
6.此時python3已經裝好,在命令列中輸入python3測試
7.(可選,我沒做)修改yum配置檔案,python2與python3共存
vi /usr/bin/yum
把#! /usr/bin/python修改為#! /usr/bin/python2(配置檔案第一行)
同理
vi /usr/libexec/urlgrabber-ext-down
把檔案裡面的#! /usr/bin/python 也修改為#! /usr/bin/python2
此時完成python3安裝,且實現與python2共存,保持yum命令可用
下面是Ubuntu配置:
sudo apt-get install gcc
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev
安裝好之後將一些檔案開頭改成系統的python版本,避免衝突
vim /usr/lib/command-not-found
vim /usr/bin/gnome-terminal
8、將編譯好的python3遷移到主機2中使用
檢視主機2,確認沒有
只需要編譯安裝產生的檔案,不需要壓縮包和解壓檔案
新主機中檢查沒有python3,建立軟連線。
還是沒有
連結錯地方了,額,我是放到opt下面了。重新建立連結就可以了。
寫個程式都是正常執行
centos7自帶python2,由於執行yum需要python2,所以即使安裝了python3也不能刪除python2
1.安裝依賴包
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
2.下載自己需要的python版本,例如python3.7.1,下載要花費一段時間,要耐心等待
yum -y install wget
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
3.新建一個資料夾存放python3
mkdir /usr/local/python3
4.把安裝包移動到該新建資料夾下,解壓安裝包,安裝python3,依次執行以下命令,花費時間較長,耐心等待
mv Python-3.7.1.tar.xz /usr/local/python3
tar -xvJf Python-3.7.1.tar.xz
cd Python-3.7.1
./configure --prefix=/usr/local/python3
make
make install
5.建立軟連線
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
6.此時python3已經裝好,在命令列中輸入python3測試
7.修改yum配置檔案,python2與python3共存
vi /usr/bin/yum
把#! /usr/bin/python修改為#! /usr/bin/python2(配置檔案第一行)
同理
vi /usr/libexec/urlgrabber-ext-down
把檔案裡面的#! /usr/bin/python 也修改為#! /usr/bin/python2
此時完成python3安裝,且實現與python2共存,保持yum命令可用
下面是Ubuntu配置:
sudo apt-get install gcc
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev
安裝好之後將一些檔案開頭改成系統的python版本,避免衝突
vim /usr/lib/command-not-found
vim /usr/bin/gnome-terminal
安裝過程詳解
centos7自帶python2,由於執行yum需要python2,所以即使安裝了python3也不能刪除python2
1.安裝依賴包
yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
開發工具包組沒安裝上,下面的包都裝上了
2.下載自己需要的python版本,例如python3.7.1,下載要花費一段時間,要耐心等待
yum -y install wget
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
3.新建一個資料夾存放python3
mkdir /usr/local/python3
4.把安裝包移動到該新建資料夾下,解壓安裝包,安裝python3,依次執行以下命令,花費時間較長,耐心等待
mv Python-3.7.1.tar.xz /usr/local/python3
cd /usr/local/python3
tar -xJf Python-3.7.1.tar.xz
cd Python-3.7.1
./configure --prefix=/usr/local/python3
make
make install
5.建立軟連線
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
6.此時python3已經裝好,在命令列中輸入python3測試
7.(可選,我沒做)修改yum配置檔案,python2與python3共存
vi /usr/bin/yum
把#! /usr/bin/python修改為#! /usr/bin/python2(配置檔案第一行)
同理
vi /usr/libexec/urlgrabber-ext-down
把檔案裡面的#! /usr/bin/python 也修改為#! /usr/bin/python2
此時完成python3安裝,且實現與python2共存,保持yum命令可用
下面是Ubuntu配置:
sudo apt-get install gcc
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev
安裝好之後將一些檔案開頭改成系統的python版本,避免衝突
vim /usr/lib/command-not-found
vim /usr/bin/gnome-terminal
8、將編譯好的python3遷移到主機2中使用
檢視主機2,確認沒有
只需要編譯安裝產生的檔案,不需要壓縮包和解壓檔案
新主機中檢查沒有python3,建立軟連線。
還是沒有
連結錯地方了,額,我是放到opt下面了。重新建立連結就可以了。
寫個程式都是正常執行