Python3在ubuntu環境下的安裝

來源:互聯網
上載者:User

首先下載最新版本的Python,在這裡我的版本是Python3.1.1。然後就是安裝,切換到Python的檔案目錄下:

  1. ./configure
  2. make
  3. make test
  4. sudo make install

     
在這裡可能會遇到幾個問題,第一個是在./configure時,可能會出現C compiler cannot create
executables,對於這個問題的解決,可以使用sudo apt-get install build-essential命令來解決。

 

由於程式使用的是python3.0新平台,今天在Ubuntu上嘗試安裝Python3.2.2(Ubuntu上內建的是2.x版本的 python)。最初只是下載源碼,編譯後發現很多庫都用不了。後來才發現原來是要先安裝很多庫,然後再安裝python,總結如下,讓後來者少走彎路。

注意下文均在root下完成的,如果其它使用者需要用sudo。

 

1, apt-get install build-essential libncursesw5-dev libreadline5-dev libssl-dev libgdbm-dev libc6-dev libsqlite3-dev tk-dev libbz2-dev
2, Download Python-3.2.2.tar.bz2 from the official website.
3, tar -xjvf Python-3.2.2.tar.bz2
4, cd Python-3.2.2
5, ./configure
6, make
7, make altinstall #install along with python2.x
8, cd /usr/bin
9, rm python  #remove original symbolic link
10, ln -s python3.2 python # create a new symbolic link(目錄可能是/usr/local/bin)


     
還有一個問題是在安裝完成後,使用Python命令來測試安裝是否成功時,如果以前預裝了Python2.6,仍然會顯示舊有的版本。原因在於安裝時沒有
設定--prefit,預設安裝在/usr/local目錄,/usr/bin檔案仍然串連到原有的Python版本。解決方案是:

  1. sudo rm /usr/bin/python
  2. sudo ln /usr/local/python*
    /usr/bin/python即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.