centos下安裝python常用版本的方法

來源:互聯網
上載者:User

安裝python2.7.3

 代碼如下 複製代碼

wget -c http://python.org/ftp/python/2.7.3/Python-2.7.3.tgz
tar zxvf Python-2.7.3.tgz
cd Python-2.7.3
./configure
make && make install
mv /usr/bin/python /usr/bin/python_bak
ln -s /usr/local/bin/python /usr/bin/python
echo “/usr/local/lib” >>/etc/ld.so.conf

安裝python3

下載:

 代碼如下 複製代碼

wget -c http://www.python.org/ftp/python/3.1.3/Python-3.1.3.tar.bz2

解壓編譯安裝:
$ tar –jxvf Python-2.5.2.tar.bz2
$ cd Python-2.5.2
$ ./configure
$ make
$ make install

由於centos預設安裝有2.4,直接輸入python進行的是2.4

 代碼如下 複製代碼

# python
Python 2.4.3 (#1, Dec 11 2006, 11:38:52)
[GCC 4.1.1 20061130 (Red Hat 4.1.1-43)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>>

如下修改可以解決

 代碼如下 複製代碼

cd  /usr/bin
ll |grep python
ln -s /root/Python-3.1.3/python  ./python    ///root/Python-3.1.3/python為解壓目錄
現在輸入python顯示為3.1的了
[root@chxy bin]# python
Python 3.1.3 (r313:86834, Jan  2 2011, 02:12:38)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-48)] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
>>>

聯繫我們

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