码迷,mamicode.com
首页 > 编程语言 > 详细

python2.7安装完后,执行python时,出现import readline ImportError: No module named readline 以及tab补全

时间:2017-05-04 19:58:34      阅读:1134      评论:0      收藏:0      [点我收藏+]

标签:too   4.4   安装   mod   parse   package   oca   pac   51cto   

yum安装readline、readline-devel

#yum install -y readline-devel

下载安装setuptools

#wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e --no-check-certificate

#tar -zxvf setuptools-0.6c11.tar.gz

#cd setuptools-0.6c11

#python setup.py install

 

下载安装readline

#wget https://pypi.python.org/packages/source/r/readline/readline-6.2.4.1.tar.gz#md5=578237939c81fdbc2c8334d168b17907 --no-check-certificate

#tar -zxvf readline-6.2.4.1.tar.gz

#cd readline-6.2.4.1

#python setup.py install

 

# python

Python 2.7.5 (default, Sep 27 2014, 17:30:23)

[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2

Type "help", "copyright", "credits" or "license" for more information.

>>> import readline

 


切换到python目录,我的系统是/usr/local/python27/lib/python2.7

编辑tab.py脚本

#!/usr/bin/env python
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)

 



授权

#chmod 755 /usr/local/python27/lib/python2.7/tab.py

 

修改根目录的.bashrc文件

添加如下一行

export PYTHONSTARTUP=/usr/local/python27/lib/python2.7/tab.py

 

重新加载环境变量

#source .bashrc

 

这样再进入python编辑器就可以自动补全啦

 

本文出自 “Jeff” 博客,请务必保留此出处http://zhangxz.blog.51cto.com/5490116/1559297

python2.7安装完后,执行python时,出现import readline ImportError: No module named readline 以及tab补全

标签:too   4.4   安装   mod   parse   package   oca   pac   51cto   

原文地址:http://www.cnblogs.com/augustyang/p/6809013.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!