使用yum 时出现以下错误
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
这是由于升级python造成的
vim /usr/bin/yum
把 #!/usr/bin/python2 改为 #!/usr/bin/python2.6
--------------------------------------
方向键乱码
使用python时方向键出现^[[A^[[B^[[D^[[C^H
CentOS 6.5默认只安装了readline模块而没有安装readline-devel模块,所以只要安装下即可
yum install readline-devel -y
进入python3的源码目录,重新编译下
make
make install
--------------------------------------------
Tab 自动补全
安装readline
yum install readline* -y
创建pythonstartup文件,位置随便放,我是放在/usr/local/python3下
# python startup file import sys import readline import rlcompleter import atexit import os # tab completion readline.parse_and_bind(‘tab: complete‘) # history file histfile = os.path.join(os.environ[‘HOME‘], ‘.pythonhistory‘) try: readline.read_history_file(histfile) except IOError: pass atexit.register(readline.write_history_file, histfile) del os, histfile, readline, rlcompleter
在~/.bash_profile中添加环境变量
export PYTHONSTARTUP=/usr/local/python3/pythonstartup
刷新配置
source .bash_profile
时间: 2024-10-11 05:54:14