What to do if you can't hit the arrow keys in the Python interactive console

Here's what to do about a problem you've encountered while trying out some code in the Python interactive console.

environment

$ python  
Python 3.5.6 (default, Sep 28 2019, 10:29:54) 
[GCC 7.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

What kind of trouble was it

When I typed the arrow keys in the interactive console, I typed an unintended character. Specifically, if you enter the parentheses first like "method name ()" and then use the arrow keys to return to the parentheses and try to input, the following characters will appear.

>>> def index()^[[D

The above is the left key. --Right: ^ [[D --Top: ^ [[A --Bottom: ^ [[B

Unintended characters are entered, such as.

Workaround

I solved it by putting the library in pip.

$ pip install gnureadline

On the other hand, according to pypi (gnu readline)

Please take note that IPython does not depend on gnureadline anymore since version 5.0 as it now uses prompt_toolkit instead.
(Note that since version 5.0, IPython uses prompt_toolkit instead, so it no longer depends on gnureadline.)

It is said that gnu readline is no longer dependent on the old version, but in the old version like the virtual environment (python 3.5) I set up, the interactive console worked safely by installing this library.

reference: pypi(gnureadline) stackoverflow

Recommended Posts

What to do if you can't hit the arrow keys in the Python interactive console
What to do if you can't use the trash in Lubuntu 18.04.
What to do if you can't use scikit grid search in Python
What to do if you get a minus zero in Python
What to do if you can't pipenv shell
What to do if you can't find PDO in Laravel or CakePHP
What to do if you can't install with pip in babun environment
What to do if you can't pip install mysqlclient
What to do when you can't bind CaboCha to Python
What to do if ʻarguments [0] .scrollIntoView ();` fails in python selenium
What to do if you get `No kernel for language python found` in Hydrogen
What to do if you get "coverage unknown" in Coveralls
What to do if you get an error when importing matplotlib in Python (Mac)
What to do if you can't sort files with subscripts
What to do if the progress bar is not displayed in tqdm of python
How to install and use pyenv, what to do if you can't switch python versions
What to do if you can't use WiFi on Linux
What to do if Python does not switch from the System version in pyenv
What to do if you run python in IntelliJ and end with an error
What to do if you get Swagger-codegen in python and Import Error: No module named
What to do if you can't build your project with Maven
What to do when you get "I can't see the site !!!!"
What to do when the value type is ambiguous in Python?
What to do if you get angry with'vertices' must be a 2D list ... in matplotlib arrow
What to do if you can't find well with grep's -f option
What to do if there is a decimal in python json .dumps
What to do if you get lost in file reference with FileNotFoundError
What to do if you get angry in TensorFlow v2 without attribute'app'
What to do if No Python documentation found for ... appears in pydoc
What to do if the server doesn't start with python manage.py runserver
What happens if you do "import A, B as C" in Python?
What to do if you get `locale.Error: unsupported locale setting` when getting the day of the week from a date in Python
What to do if pipreqs results in UnicodeDecodeError
What to do if you get a "Wrong Python Platform" warning when using Python with the NetBeans IDE
What to do if you get angry with "Value Error: unknown local: UTF-8" in python manage.py syncdb
[Python] What to do if you get a ModuleNotFoundError when importing pandas using Jupyter Notebook in Anaconda
What to do if you get the error Target WSGI script'/var/www/xxx/xxx.wsgi' cannot be loaded as python module
[Python] What to do if an error occurs in pip (pyinstaller, pyautogui, etc.)
What to do if you get a "No versions found" error in pipenv
What to do if a Unicode Encode Error occurs in Sublime Text Python
What to do if you get an error when installing python with pyenv
What to do if a version error occurs in the selenium Chrome driver
What to do if pip install fails in Xcode 5.1
No module named What to do if you get'libs.resources'
To do the equivalent of Ruby's ObjectSpace._id2ref in Python
What to do if you get the error RuntimeError: Python is not installed as a framework when trying to use matplitlib and pylab in Python 3.3
What to do if you get "(35,'SSL connect error')" in pycurl (one of them)
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux
What to do if you get the error "Error: opencv3: Does not support building both Python 2 and 3 wrappers" when installing openCV 3
[python] How to check if the Key exists in the dictionary
Why do you add a main ()-if statement in Python?
[Python version] Why can't you do object-oriented development in Java?
What to do if the package dependency cannot be repaired
What to do if you are addicted to Windows character code
If you write TinderBot in Python, she can do it
What to do if pip gives a DistributionError in Homebrew
What you can do with the Python standard library statistics
What to do when "SSL: CERTIFICATE_VERIFY_FAILED _ssl.c: 1056" appears in Python
What to do if you lose your EC2 key pair
[* CentOS 6.10] What to do if you cannot add the IUS Community Project repository on CentOS 6.5 (VirtualBox)
Make a note of what you want to do in the future with Raspberry Pi