原文:http://www.whatled.com/post-1019.html
1.下載源碼 http://www.python.org
- 安裝
'''
$ tar -jxvf python2.7.12.tgz
$ cd python2.7.12
$ ./configure
$ make
$ make install
'''
3月92014
ubuntu下安裝python
作者:admin 發(fā)布:2014-3-9 20:51 Sunday 分類:編程開發(fā) 閱讀:5872次 評論: 暫無評論
1.下載源代碼 http://www.python.org 2.安裝
$ tar –jxvf Python-2.7.3.tgz
$ cd Python-2.7.3
$ ./configure
$ make
$ make install
3. 測試
在命令行下輸入python,出現(xiàn)python解釋器即表示已經(jīng)正確安裝。
在suse10或rhel5(es5)下系統(tǒng)默認(rèn)已經(jīng)裝了python但版本是2.4.x;本次安裝后在shell中輸入
#python
會發(fā)現(xiàn)顯示結(jié)果:
# 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 “l(fā)icense” for more information.
版本還是2.4.x的
解決辦法:
#cd /usr/bin
#ll |grep python//查看該目錄下python
#rm -rf python
#ln -s PREFIX/Python-2.5.2/python ./python//PREFIX為你解壓python的目錄
#python
# python
Python 2.5.2 (#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 “l(fā)icense” for more information.
OK!問題解決!
問題描述:
Ubuntu 12中默認(rèn)就自帶了python的2.7版本,我自己安裝了一個python3.2的版本,可是如果你不設(shè)置環(huán)境變量,那么在終端中運(yùn)行的python都是系統(tǒng)默認(rèn)的版本,這樣就會導(dǎo)致3.2的程序在終端下無法運(yùn)行,沒有辦法必須要將默認(rèn)的python版本換到3.2.
問題分析:
其實(shí)在linux系統(tǒng)中多個python版本是可以共存的,只不過在終端中運(yùn)行的時候,輸入 python2.7 或者 python3.2 就能進(jìn)入不同的版本了,而且在你的*.py文件中可以用 #!/usr/bin/python 來指定程序的解釋器版本,不過這樣使用起來有些不方便,所以就把/usr/bin/python這個快捷方式的指向修改下好了。
解決方法:
: ~$ sudo rm /usr/bin/python
:~$ sudo ln -s /usr/include/python3.2 /usr/bin/python
這樣在終端中輸入python默認(rèn)就是 3.2版本了