0

I have python3.10 on CentOS and command line editing and history recall doesn't work within the interactive python shell. (It does in python2 which is also installed as it is necessary for lots of system related scripts.) I also have python3.6 on an older CentOS where it also works fine.

I am talking about up/down/left/right arrows, ctrl-a/ctrl-e for beginning of line/end of line etc. The usual linux/unix command line editing keys.

Is there a setting somewhere that I am not aware of?

Thanks.

gbohus
  • 11
  • 3
  • Look at https://groups.google.com/g/comp.lang.python/c/MncdmV_9SCA and https://medium.com/@oalejel/printing-command-history-within-the-python-interactive-terminal-repl-simplified-5fd202c64880. You might have something in .pythonrc or env. variable PYTHONSTARTUP. – Nic3500 Jun 03 '22 at 16:27
  • or https://stackoverflow.com/questions/3483723/python-interactive-mode-history-and-arrow-keys – Nic3500 Jun 03 '22 at 16:29
  • Adding readline in the build solved the problem, although I had some difficulties building python. all is good now. – gbohus Jun 04 '22 at 18:48

1 Answers1

0

As mentioned in the old https://medium.com/@oalejel/printing-command-history-within-the-python-interactive-terminal-repl-simplified-5fd202c64880 link, building with readline support solved the problem.

Comment out the appropriate lines in Modules/Setup:

readline readline.c -lreadline -ltermcap

You might need to install readline-devel first:

sudo yum install readline-devel

gbohus
  • 11
  • 3
  • 1
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jun 05 '22 at 00:15