question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Randomly broken input function

See original GitHub issue

Issue 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: InputProblem

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:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
TBSenseocommented, Jun 7, 2022

Hey everyone, please update to qtconsole 5.3.1 to get the fix for this problem. We’ll add a dependency on that version in our next Spyder version (5.3.2) so that users don’t have to manually do that. But for now, that’s what you need to.

Thanks. I had not had the issue since I updated Spyder and then downgraded Jupyter.

0reactions
ccordoba12commented, Jun 7, 2022

Great! Glad to know that Qtconsole version fixed the problem for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Broken loop in Python - Stack Overflow
User will be stuck in infinite loop unless somewhere within the while loop the condition is changed by setting inputOK = True ....
Read more >
How to avoid broken formulas - Microsoft Support
Formulas can sometimes result in error values in addition to returning unintended results. Learn about best practices to avoid those problems.
Read more >
Broken analog inputs? - Troubleshooting - Arduino Forum
Hi, when im reading value of analog pin's, some pin give strange values. I think pins 0,1,2,3 works, but others are broken.
Read more >
Fixing JavaScript's Broken Random Number Generator
szczys writes: It is surprising to learn how broken the JavaScript Random Number Generator has been for the past six years.
Read more >
installation of the New Input System breaks cinemachine (Or is ...
the fixed or dynamic? Is this option set up wrong in the Unity version 2021.2.0f1 or is set up correctly and cinemachine asset...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found