作为一个新手,在看别人安装ptyhon的时候用了tab插件然而当我想弄的时候发现在import tab的时候出现错误:import readline,ImportError: No module named readline
后面去搜索到了别人的办法,受到启发。
AFAIK, the default Python environment in Ubuntu 10.04 is Python 2.6.5, so you must be using a self-compiled python.
You should be missing some readline header files when building your python 2.7.2, so you have two choices now:
1.Re-compile your python, with libreadline?-dev installed.
2.Install the standalone version of readline, using pip
install readline or easy_install
readline
首先感谢一下这个人,很明显从上面看到了两种办法一种重新编译pyhton,一种是pip安装readline。
当然我选择了第二种毕竟第二种感觉对新手的感觉更简单。
然后再pip的时候提示需要settools,然后我又去安装 settools,结果出现一个 c编译不过去 的错误:
/usr/bin/ld: cannot find -lncurses
结果只能放弃最终孤注一掷,备份好系统。
使用第一种办法,最后问题得以解决!
如下步骤:
1、tar -jxvf Python-2.7.5.tar.bz2 python官网有得下载
2、./configure --prefix=$user_root/software/Python/Python-2.7.5/ --with-readline
3、&& make && make install
4、ln -s -f $user_root/software/Python/Python-2.7.5/bin/* $user_root/bin 链接python
5、PATH=$user_root/bin:$PATH 改变路径
结束。
附上某处抄的shell:
if [ ! -d ~/software/Python/Python-2.7.5 ]; then
mkdir ~/software
mkdir ~/software/Python
mkdir ~/software/Python/Python-2.7.5
fi
if [ ! -d ~/bin ]; then
mkdir ~/bin
fi
user_root=~
echo $user_root
echo "unpackage Python-2.7.5.tar.bz2..."
tar -jxvf Python-2.7.5.tar.bz2
echo "prepear to install Python-2.7.5"
cd Python-2.7.5
sed -i "s/#readline/readline/g" Modules/Setup.dist
echo "Start to install Python-2.7.5"
./configure --prefix=$user_root/software/Python/Python-2.7.5/ && make && make install
echo "Make symbol link"
ln -s -f $user_root/software/Python/Python-2.7.5/bin/* $user_root/bin
echo "Set environment variable"
PATH=$user_root/bin:$PATH