Python3.5 tab补全 yum
1.安装readline模块。
yum install install readline*
2.创建startup.py
[root@gaogd python3.5]# pwd
/usr/local/lib/python3.5
[root@gaogd Python3.5]# cat startup.py
#!/usr/bin/python
# python startup file
# 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
[root@gaogd python3.5]#
3.在~/.bash_profile中添加环境变量
[root@gaogd bin]# tail -2 /etc/profile
export PYTHONSTARTUP=/usr/local/lib/python3.5/startup.py
[root@gaogd bin]#
4.刷新配置
source /etc/profile
最近在弄服务器的部署,在安装python那里耗了很久,执行python时,出现import readline,ImportError: No module named readline。后来查找原因是readline没有安装成功,然后在SUSE的安装盘中找到readline-32bit-5.1-24.26.20.x86_64.rpm,readline-5.1-24.26.20.x86_64.rpm,readline-devel-32bit-5.1-24.26.20.x86_64.rpm,readline-devel-5.1-24.26.20.x86_64.rpm。安装这四个包之后重新编译安装,发现还是不行。然后我就把make的输出全部定位到文件中去,make
> make.log。这个之后我发现有这个一个错误输出,can not load shared object libreadline-so.6,然后做一个连接文件到libreadline,ln -s /usr/local/lib/libreadline.so.6.2 /usr/lib64/libreadline.so.6。然后重新编译安装python。运行python的时候就没有再报错了。
升级到python3.5之后,发现yum不能使用
出现下面问题:
[root@gaogd bin]# yum install vim
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
[root@gaogd bin]#
解决:
[root@Nginx ~]# vim /usr/bin/yum
#将!/usr/bin/python改成!/usr/bin/python2.6即可。
原来是由于升级了默认的python导致的后果,《升级Centos 6.4 默认Python》。问题找到,那么就比较容易解决了。
相关文章