Linux系统自带的python版本通常都比较低,可以在python官方网站(http://www.python.org/download/)下载最新源码包,然后进行升级安装。
1.下载python源码包。
1
|
wget http:
/
/
www.python.org
/
ftp
/
python
/
2.7
.
5
/
Python
-
2.7
.
5.tar
.bz2
|
2.解压,编译安装。
1
2
3
4
|
tar
-
jxvf Python
-
2.7
.
5.tar
.bz2
cd Python
-
2.7
.
5
.
/
configure
-
-
prefix
=
/
usr
/
local
/
python2.
7.5
make && make install
|
3.指定新python安装路径。
1
2
3
4
5
6
7
8
|
python
-
V
#查看系统之前python版本
Python
2.4
.
3
which python
#查看之前系统python可执行文件的路径
/
usr
/
bin
/
python
mv
/
usr
/
bin
/
python
/
usr
/
bin
/
python.bak
ln
-
s
/
usr
/
local
/
python2.
7.5
/
bin
/
python
/
usr
/
bin
/
python
#指定新版本路径
python
-
V
Python
2.7
.
5
|
Python升级安装就这么简单,下面介绍标准python shell的自动补齐功能,如果在编译时增加了readline特性,将具有tab自动完成功能,对python编程或者初学者都有很大的帮助。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
python
Python
2.7
.
5
(default, Jun
13
2013
,
15
:
08
:
30
)
[GCC
4.1
.
2
20080704
(Red Hat
4.1
.
2
-
46
)] on linux2
Type
"help"
,
"copyright"
,
"credits"
or
"license"
for
more information.
>>>
import
rlcompleter,readline
>>> readline.parse_and_bind(
'tab: complete'
)
>>>
import
time
>>> time.
time.__class__( time.__reduce__( time.daylight
time.__delattr__( time.__reduce_ex__( time.gmtime(
time.__dict__ time.__repr__( time.localtime(
time.__doc__ time.__setattr__( time.mktime(
time.__file__ time.__sizeof__( time.sleep(
time.__format__( time.__str__( time.strftime(
time.__getattribute__( time.__subclasshook__( time.strptime(
time.__hash__( time.accept2dyear time.struct_time(
time.__init__( time.altzone time.time(
time.__name__ time.asctime( time.timezone
time.__new__( time.clock( time.tzname
time.__package__ time.ctime( time.tzset(
|
有关python升级安装和Tab用法就学习到这里,接下来学习python模块。
备注:python交互式模式里面不能按回格键(Backspace)解决版本, yum install readline-devel 然后重新编译安装即可。
本文转自 sfzhang 51CTO博客,原文链接:http://blog.51cto.com/sfzhang88/1221258,如需转载请自行联系原作者