CentOS7下安裝Python3及Pip3並保留Python2

1. 安裝依賴環境python

# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-develsql

 

2. 瀏覽器打開 https://www.python.org/ftp/python/ 查看最新的Python版本,標記爲3.A.B瀏覽器

# wget https://www.python.org/ftp/python/3.A.B/Python-3.A.B.tgz測試

 

3. 建立Python3的目錄sqlite

# mkdir /usr/local/python3ip

 

4. 解壓下載文件並切換目錄ssl

# tar -zxvf Python-3.A.B.tgzget

# cd Python-3.A.Bopenssl

 

5. 執行it

# ./configure --prefix=/usr/local/python3

# make && make install

 

6. 建立Python3的軟連接

# ln -s /usr/local/python3/bin/python3 /usr/bin/python3

 

7. 建立Pip3的軟連接

# ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

 

8. 測試命令 python3 和 pip3

# python3

# pip3

 

安裝保留了原python命令調用python2

安裝完成

相關文章
相關標籤/搜索