Hex_27
Hex_27

Reputation: 103

Python3 input() not interactive

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?

Upvotes: 0

Views: 356

Answers (2)

Ran Cohen
Ran Cohen

Reputation: 751

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

Upvotes: 1

Hex_27
Hex_27

Reputation: 103

python3 -i script.py

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

Upvotes: 0

Related Questions