在Linux上安裝Python3

來源:互聯網
上載者:User

標籤:linu   ogr   art   amp   yum   oca   wget   解壓   退出   

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

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

3.安裝python3

  我個人習慣安裝在/usr/local/python3(具體安裝位置看個人喜好)
  建立目錄:

# mkdir -p /usr/local/python3

  解壓下載好的Python-3.x.x.tgz包(具體包名因你下載的Python具體版本不不同?而不不同,如:我下載的是Python3.6.1.那我這裡就是Python-3.6.1.tgz)

# tar -zxvf Python-3.6.1.tgz

4.進入解壓後的目錄,編譯安裝。

# cd Python-3.6.1# ./configure --prefix=/usr/local/python3

  make

# make

  make install

make install    或者 make && make install

5.建立python3的軟鏈

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

6.並將/usr/local/python3/bin加入PATH

# vim ~/.bash_profile# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then. ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/bin:/usr/local/python3/binexport PATH

  按ESC,輸入:wq斷行符號退出。

  修改完記得執行行下面的命令,讓上一步的修改生效:

# source ~/.bash_profile

  檢查Python3及pip3是否正常可用:

# python3 -VPython 3.6.1# pip3 -Vpip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)

7.不行的話嘗試建立一下pip3的軟連結

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

在Linux上安裝Python3

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.