0

I have this test snippet

while True:
    input("prompt> ")

On Windows, when I run this script with "py", I can use the arrow keys as expected. But when I try doing this in my ubuntu command line, it will show the following output: enter image description here

How do I make it such that this code snippet is interactive for any python3 installation on any OS? Why is it only working on Windows now?

Hex_27
  • 103
  • 7

2 Answers2

1

it's about OS -
windows os is working differently from a based Linux-OS like ubuntu. you can try this:
https://stackoverflow.com/a/893200/9350669

by the way, I just install python3 in my VM-ubuntu and run your script and the arrow keys work well, so you can try reinstall python or update the os. enter image description here

Ran Cohen
  • 721
  • 6
  • 15
  • 1
    It looks like one of the links in that link has an answer. If I import the readline module in my main python script, arrow keys work. It's a little bit wonky (Sometimes "prompt" gets replaced) but it's much better than nothing – Hex_27 Aug 16 '20 at 10:25
0
python3 -i script.py

Apparently this solves the problem and makes the session interactive. Lol okay.

Hex_27
  • 103
  • 7