6

I am using Python 3.6.2 on Ubuntu 16.04. On all prior versions of Python, I have never had this issue. I have googled around. There is no post on AskUbuntu on this specific issue that I could find. There is one on SO, but it is pretty old. I don't have etc/pythonstart as the accepted answer suggests and this is the ONLY place I've found that even references such a thing.

This SO answer is also old, but when I tried the solution:

malikarumi@Tetuoan2:~$ apt-get libreadline-dev
E: Invalid operation libreadline-dev
malikarumi@Tetuoan2:~$ sudo apt-get libreadline-dev
[sudo] password for malikarumi: 
E: Invalid operation libreadline-dev
malikarumi@Tetuoan2:~$ apt-get libreadline
E: Invalid operation libreadline
malikarumi@Tetuoan2:~$ sudo apt-get libreadline
E: Invalid operation libreadline
malikarumi@Tetuoan2:~$ apt-get readline
E: Invalid operation readline
malikarumi@Tetuoan2:~$ sudo apt-get readline
E: Invalid operation readline

I do have the GNU Readline Library, up to 6, in usr/share/doc, so I don't know why that's not working for me since, as I said, I never had this issue on <3.6

So since this seems more like a OS issue than a Python one, I decided to post here. Suggestions? And let me know if the rebuild is still necessary. Thanks.

Malik A. Rumi
  • 533
  • 3
  • 9
  • 16
  • 1
    Where do you have Python 3.6 from/how did you install it? The version from Ubuntu's repositories for 16.04 is 3.5 only. Also the command you seem to have tries would need to be `sudo apt install libreadline-dev`, but the answer mentioned this only changes anything if you compile the Python interpreter from source. – Byte Commander Sep 24 '17 at 18:27
  • @ByteCommander right, that's why I was asking if the rebuild from source suggestion still applies. I got this from python.org. And you're right, sudo apt-get install works. Thanks. Do you want to make this an answer so I can accept it? – Malik A. Rumi Sep 24 '17 at 18:36

3 Answers3

8

Installing gnureadline package instead of readline one solved my problem

pip install gnureadline

https://stackoverflow.com/a/44210086/12562703

  • The description of the package says that Ubuntu should already use proper readline and you shouldn't have to install it https://pypi.org/project/gnureadline/ What Ubuntu version are you using? – int_ua Apr 07 '21 at 20:24
6

As you said in comments, fixing the command to install the libreadline-dev package as suggested by the post on SO you linked seems to have solved your problem.

Here is the correct command again:

sudo apt install libreadline-dev
Byte Commander
  • 105,631
  • 46
  • 284
  • 425
3

I believe this question has been addressed on SO. Aside from libreadline-dev, you may need to run sudo pip install readline

https://stackoverflow.com/questions/893053/seeing-escape-characters-when-pressing-the-arrow-keys-in-python-shell

Jon
  • 320
  • 1
  • 8