Pycharm console - input function not working

Completed

I have a small but very annoying problem. Your help would be greatly appreciated.

A simple input() function does not work in PyCharm console..

example code:

Then the console will not take any other input whatsoever, it will always return “>?” no matter what I press. It's as if the console does not recognize the function input(), or it is corrupted somehow?

This only happens in PyCharm console. It works as expected outside of PyCharm and also works as a script in PyCharm.

I just uninstalled/reinstalled PyCharm without success.

I'm running:

  • PyCharm community edition (version 2017.3.2)
  • Python Anaconda3 
  • Windows 10 

Any suggestion on a fix?

Thank you again!

21 comments
Comment actions Permalink

Also have this problem, following

0
Comment actions Permalink

same

 

edit: seems it is fixed in the next release https://youtrack.jetbrains.com/issue/PY-27891

0
Comment actions Permalink

Thank you a lot, @Irmen.

0
Comment actions Permalink

Today,new release Pycharm fixed this problem,Thank you all!

0
Comment actions Permalink

I still have this problem in 2018.2.4, actually never mind, I only have this problem if I am running with the "Emulate terminal in output console" switch enable.

0
Comment actions Permalink

Yeah. This is definitely still a problem and causing me pain. I am currently working on a command line style app. I need to have the "Emulate terminal in output console" checked for the output functionality, but then the input functionality doesn't work.

1
Comment actions Permalink

Hi Howard,
Could you please clarify what is your project interpreter?

Please upload your logs folder zipped (Help | Show Log in...) after reproducing the problem to 

https://uploads.services.jetbrains.com and let me know the name of that zip file.

0
Comment actions Permalink

OK. I created small sample app to verify the issue. The project interpreter is venv directory of the project:

This issue only occurs when "Emulate terminal in output console" is checked:

If I uncheck this or run directly from terminal the input functionality will work. However, calls to isatty() will fail which causes other aspects of my full project not to function.

I have uploaded idea.log to the link you provided.

Thanks,
Howard

0
Comment actions Permalink

Thanks!

Could you please provide a sample code and a screenshot showing the problem?

 

0
Comment actions Permalink

I get a problem with the sample provided on your "First steps: Creating and Running Your First Python Project. I do everything exactly as instructed, and when I run it and try to enter anything in the console, I get this:

C:\localization\Python\venv\Scripts\python.exe C:/localization/PyCharmProjects/Car/Car.py
I'm a car!
What should I do? [A]ccelerate, [B]rake, show [O]dometer, or show average [S]peed?a
Traceback (most recent call last):
File "C:/localization/PyCharmProjects/Car/Car.py", line 28, in <module>
action = input("What should I do? [A]ccelerate, [B]rake, "
File "<string>", line 1, in <module>
NameError: name 'a' is not defined

Process finished with exit code 1

If I enter the input with quotes, like 'a' then it works. This is a fresh installation, using VirtualEnv Python 3.6, just following the steps in the guide.

0
Comment actions Permalink

I was actually able to fix mine. For some reason, even though I created the project as using VirtualEnv 3.6, both the Python Console > Python interpreter and the Project interpreter were set to Python 2.7... After changing those to 3.6, it started working.

0
Comment actions Permalink

@Sergey main.py is simply:

command = input("enter a command: ")
print('The command is ' + command)

If I type something at the prompt, I see nothing until I press the enter key:


In this case I have just typed the word 'test' and nothing has appeared on the screen. If I press enter I see:







1
Comment actions Permalink

Thanks for clarification.

It's a known problem https://youtrack.jetbrains.com/issue/PY-32658, please vote for it and follow for updates. 

See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.

0
Comment actions Permalink

Voted and watched. Thanks Sergey.

0
Comment actions Permalink

The problem with the Python input() method is now solved and everything works fine.

I have an application that takes input from stdin with raw_input. 

When debugging within PyCharm, it used to work in exactly the same way.

Best regards,

 

0
Comment actions Permalink

Hi,

Seems not to be working if remote kernel is used.

Any solution for that?

0
Comment actions Permalink

Hello, 

There is an existing issue https://youtrack.jetbrains.com/issue/PY-29157 , do you experience the same behavior? If yes, please vote for the ticket in order to increase its priority. 

0
Comment actions Permalink

The problem with the Python input() method is now solved and everything works fine.

I have an application that takes input from stdin with raw_input. 

When debugging within PyCharm, it used to work in exactly the same way.

Best regards,

0
Comment actions Permalink

Hi all, I am very very new to coding... Decided to begin with Python.  I am having a very similar problem lol. Using PyCharm on a macbook.

Input:

"name = input("your name please: ")
print (name)"

Output:

your name please: ofd
Traceback (most recent call last):
File "/Users/ofd/PycharmProjects/giraffe/app_2.py", line 1, in <module>
name = input("your name please: ")
File "<string>", line 1, in <module>
NameError: name 'ofd' is not defined

Process finished with exit code 1

Cant resolve the problem.

 

Any help is appreciated. Regards.

Ömer

 

0
Comment actions Permalink

Hello @Ofdogan44, please attach a screenshot of the Run/Debug Configuration https://www.jetbrains.com/help/pycharm/creating-and-editing-run-debug-configurations.html and the editor view with the Run output after the script execution.

 

 

0
Comment actions Permalink

Hi Ofdogan44, I'm also very new to coding and had the same problem.  I eventually figured it out —  Pycharm by default uses an older version of Python (2), which interprets the "input" function differently. This problem can be fixed by changing the version of Python that Pycharm uses to Python 3, which can be done as follows:

In the very bottom right of the Pycharm window, there is a figure that says which version of Python is being used.  If you click it, you can then "Add Interpreter."  I added "Conda Environment" 3.10.  It took a second to configure, but then the simple program worked as expected.   

Hope this helps, and good luck learning!

0

Please sign in to leave a comment.