Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"ImportError: No module named readline" running "repo init"

I downloaded the source of Android, but when I used repo init according to the website, I got the following error:

Traceback (most recent call last):
  File "/root/bin/repo", line 91, in <module>
    import readline
ImportError: No module named readline

I am using Ubuntu 10.04 and Python 2.7.2

like image 739
enterzhu Avatar asked Oct 22 '25 03:10

enterzhu


2 Answers

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
like image 138
Felix Yan Avatar answered Oct 23 '25 20:10

Felix Yan


I have the same issue, and I fixed it in this way, hope it will be helpful to you.

$ source Install_Python2.7.5.sh

Shell script "Install_Python2.7.5.sh" is like this:

#!/bin/bash

sudo apt-get install libreadline-dev

sudo aptitude install build-essential libreadline5-dev

sudo apt-get install libbz2-dev

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
like image 33
yfliu Avatar answered Oct 23 '25 21:10

yfliu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!