Randomly broken input function
See original GitHub issueIssue Report Checklist
- Searched the issues page for similar reports
- Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
- Reproduced the issue after updating with
pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}
in PowerShell in the Python distribution’s Scripts folder - Could not reproduce inside
jupyter qtconsole
(if console-related) - Could not reproduce inside
python.exe .\InputProblem.py
(if console-related) - Could not reproduce inside
ipython.exe .\InputProblem.py
(if console-related) - Tried basic troubleshooting (if a bug/error)
- Restarted Spyder
- Reset preferences with
spyder --reset
- Reinstalled the latest version of Anaconda
- Tried the other applicable steps from the Troubleshooting Guide
- Completed the Problem Description, Steps to Reproduce and Version sections below
Problem Description
When I run a script that includes print statements and user input queries using the input function, the input query does not work as normal quite regularly. When it happens, it seems to skip printing the newline character before printing the text from the input function and instead prints it after the input query text. This results in that there is no newline character between the text from the last print statement and the text from the input query and the cursor for entering the input is one line after the input query.
What steps reproduce the problem?
Run a script with print and input statements from within Spyder, e. g. InputProblem.py
#!python3
# -*- coding: utf-8 -*-
"""
Created on 04/20/2022
"""
sInput = None
while sInput != '':
sInput = input('Specify another input (Keep empty to exit): ')
print(f'The input was "{sInput}".')
Run the script until the problem occurs.
What is the expected output? What do you see instead?
The expected output is that there is always a newline character between the text from the print statement and the text from the input statement and that the cursor is located at the end of the text from the input statement.
What I see:
Versions
- Spyder version: 5.3.0 None
- Python version: 3.9.12 64-bit
- Qt version: 5.15.2
- PyQt5 version: 5.15.6
- Operating System: Windows 10
I have the problem since upgrading Spyder to 5.3.0, but downgrading Spyder alone did not fix it. When I add a time.sleep(20) between the print and the input statement, then it works as intended, but I do not want to modify all scripts and libraries in the same way since the input function then still does not work as it is supposed to work.
Dependencies
No dependencies.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Thanks. I had not had the issue since I updated Spyder and then downgraded Jupyter.
Great! Glad to know that Qtconsole version fixed the problem for you.