CentOS7 安裝Python3.6.4


1. 安裝依賴環境

# 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

 

2、下載Python3.6

新建個/usr/download 文件夾

#mkdir /usr/download 

在download文件夾下下載安裝包

(/usr/download )

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz

解壓文件

tar -xvf Python-3.6.4.tgz

3、安裝Python3

創建安裝文件的路徑

mkdir /usr/local/python3

4、編譯(在解壓的文件夾下 /usr/download/python3.6.4)

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

5、安裝(在解壓的文件夾下 /usr/download/python3.6.4)

make
make install
先make再make install

6、創建新版本的軟鏈接

修改舊版本

mv /usr/bin/python /usr/bin/python_bak

創建新的軟連接  

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

檢查python的版本

python -V

  

7、配置成功后,pip3用不了,需要進一步配置

將/usr/local/python3/bin加入PATH

vim ~/.bash_profile

修改后如下:

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

export PATH

保存退出后,執行以下命令,讓上一步修改成功

# source ~/.bash_profile

完成!

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM