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!

2
23 comments

Also have this problem, following

0

same

 

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

0

Thank you a lot, @Irmen.

0

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

0

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

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

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

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

Thanks!

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

 

0

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

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

@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

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

Voted and watched. Thanks Sergey.

0

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

Hi,

Seems not to be working if remote kernel is used.

Any solution for that?

0

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

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

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

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

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!

1

emanon

Hope your well, I'm trying best to fix this issue and its still not working for me..

I did exactly what you had suggested.. I'm lost

0

Hey Raimondi ,

Not sure if this is the same problem. 

Please create an issue on YouTrack: https://youtrack.jetbrains.com/issues/PY or contact us directly with Help | Contact support. Attach logs to your request (Help | Collect Logs and Diagnostic Data) and take some screenshots of the issue (preferably with the full IDE window).

0

Please sign in to leave a comment.