您好,登录后才能下订单哦!
centos系统下需要使用tab键补全
在/usr/local/lib/python2.7/site-packages/目录下编写一个tab.py 文件
文件内容:
#!/usr/bin/python # 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
然后导入tab模块
[root@omserver ~]# python
Python 2.7 (r27:82500, Mar 18 2016, 13:43:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import tab
>>>import os
>>> os. (按tab键)
Display all 238 possibilities? (y or n)
os.EX_CANTCREAT os.WEXITSTATUS( os.chroot( os.getresgid( os.setpgid(
os.EX_CONFIG os.WIFCONTINUED( os.close( os.getresuid( os.setpgrp(
os.EX_DATAERR os.WIFEXITED( os.closerange( os.getsid( os.setregid(
os.EX_IOERR os.WIFSIGNALED( os.confstr( os.getuid( os.setresgid(
os.EX_NOHOST os.WIFSTOPPED( os.confstr_names os.initgroups( os.setresuid(
os.EX_NOINPUT os.WNOHANG os.ctermid( os.isatty( os.setreuid(
os.EX_NOPERM os.WSTOPSIG( os.curdir os.kill( os.setsid(
os.EX_NOUSER os.WTERMSIG(
........
如果在导入tab模块的时候报
wget https://pypi.python.org/packages/source/r/readline/readline-6.2.1.tar.gz#md5=9604527863378512247fcaf938100797 --no-check-certificate
tar -zxvf readline-6.2.1.tar.gz
cd readline-6.2.1
python setup.py install
如果在编译安装的过程中出现如下错误:
/usr/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
需要安装:
yum -y install gcc
找到libncurses.so
[root@omserver lib]# locate libncurses.so
/lib64/libncurses.so.5
/lib64/libncurses.so.5.7
然后
[root@omserver lib64]# cd /usr/local/lib
[root@omserver lib]# ln -sv /lib64/libncurses.so.5.7 libncurses.so
再重新编译安装
[root@omserver xmxu]# cd readline-6.2.1
[root@omserver readline-6.2.1]# python setup.py install
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。