2

I am using Python's raw_input to get input from keyboard.

How do I debug my code with PyCharm? I am unable to input from keyboard when (for example) name = raw_input("Input your name") is executed.

3 Answers 3

3

You enter the input into the console that shows up, when you compile and run your script. Like so, the green text is the input.

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

The problem was PyCharm->Properties->Build->Console>"Always show debug console" which was checked, so Python console was taking my input. I de-selected the console checkbox, and now I can do what you suggest on the screenshot. Thanks.
Another problem: now key = msvcrt.getch() doesn't work in PyCharm, but that seems to be known problem: stackoverflow.com/questions/30534218/….
It seems you also want to be sure to not check the Run Configurations option "Emulate terminal in output console, which seems odd. You may also have problems with getpass.getpass(), I can only get it working in debug mode: see stackoverflow.com/questions/28579468/…
2

For users of IntelliJ, "Always show debug console" is under IntelliJ IDEA -> Settings -> Build, Execution, Deployment -> Console

Comments

0

The workaround I found (at least for input(), but I guess it's the same problem) is to check Emulate terminal in output console in your run config. Open up your run configuration | Modify options dropdown | Emulate terminal in output console.

Always show Debug Console seems to have no effect on that problem for me.

You can also track and up-vote the issue here: https://youtrack.jetbrains.com/issue/PY-42002/Not-able-to-use-input-while-debugging-with-remote-interpreter

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.