Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input in python does not wait for my input in PyCharm

I'm using PyCharm 5.04 and Python 3.4 as interpreter. I can't use input() function in my code and simply run it (Shift+F10), because PyCharm does not give me a chance to enter my input. Here is the code:

x=''
while x!='stop':
    x=input('enter x')
    print(x)
print(x)

If I run it, I'll see:

enter x
enter x
enter x
.....

However, if I highlight the code, click right mouse button and chose in context menu 'execute selection in console', everything will work fine. Also, I can add a string 'from sys import argv' at the beginning of my cod, execute it in terminal by typing 'python name_of_script.py' and everything will be working fine to (just in case, I have ubuntu 15.10).

Is something wrong with my PyCharm settings? What should I do to be able to execute code by simple running it (with Shift+F10, as I get used)? I don't have problems with any other code if it does not have input().

Any help would be appreciated.

like image 338
user48115 Avatar asked Sep 13 '25 20:09

user48115


1 Answers

I'm posting this answer for a subtle variation of this issue that I encountered, where the Python console would not let me enter my input but unlike in your case, would not move on with the loop.

I solved the problem by clicking on "Edit the configurations" on the toolbar (run/debug configurations) and disabling the option "Emulate terminal in output console".

Hopefully those having the same issue will stumble upon this thread (as I did).

EDIT: In images:

Click on the dopdown displaying the name of the file you're working on

Click on "edit configurations"

Uncheck "Emulate terminal in output console"

I haven't tried that solution with a remote interpreter.

like image 156
L.J.M BETE Avatar answered Sep 16 '25 10:09

L.J.M BETE