发布时间:2019-07-15 10:54:04编辑:auto阅读(1327)
Centos自带的python版本太低,所以自己编译安装下python 2.7.10
安装需要的包:
[root@python ~]# yum -y install wget
[root@python ~]# yum -y install gcc
[root@python ~]# wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz
[root@python ~]# tar xf Python-2.7.10.tgz
[root@python ~]# cd Python-2.7.10
[root@python Python-2.7.10]# ./configure --prefix=/usr/local/python2.7.10
[root@python Python-2.7.10]# make
[root@python Python-2.7.10]# make install
备份系统自带的python:
[root@python Python-2.7.10]# mv /usr/bin/python /usr/bin/python_bak
[root@python Python-2.7.10]# ln -s /usr/local/python2.7.10/bin/python /usr/bin/python
查看python版本:
[root@python Python-2.7.10]# python
Python 2.7.10 (default, Dec 4 2015, 22:22:15)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
安装之后yum不能用了,修改yum文件的第一行即可
[root@python ~]# which yum
/usr/bin/yum
[root@python ~]# vi /usr/bin/yum
#!/usr/bin/python_bak
解决Python2.7.10交互模式中方向键、退格键乱码问题。安装readline-devel,装完后重新编译安装python才可以使用。
[root@python ~]# yum -y install readline-devel
上一篇: python交互式(input)
下一篇: Python-异常处理与调试
47483
45786
36783
34310
28955
25589
24436
19606
19096
17626
5458°
6041°
5557°
5632°
6558°
5370°
5370°
5877°
5850°
7163°