cent OS 7 下安裝 python 3.6


  • step1:安裝依賴環境

# 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
  • step2:下載python3.6

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz
  • step3:安裝Python3

  解壓python3.tgz

tar -xvf Python-3.6.4.tgz

  創建python3的文件路徑

mkdir /usr/local/python3
  • step4:編譯(在解壓的文件夾下)

./configure --prefix=/usr/local/python3
  • step5:安裝(在解壓的文件夾下 )

make
make install<br>先make再make install
  • step6:創建新版本軟連接

  ①修改舊版本

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

  ②創建新的軟連接

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

  ③檢查python的版本

python -V
  • step7:配置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
  • step8:更新pip3 版本

  查看當前pip3版本信息

pip3-V

  更新pip3 版本

pip3 install --upgrade pip

  查看pip3安裝的庫

pip3 freeze

完成


免責聲明!

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



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