input method throws "lost sys.stdin" in resolve console(Py3)

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

raja1975

  • Posts: 6
  • Joined: Mon Dec 27, 2021 12:23 am
  • Real Name: Raja Ranjan Senapati

input method throws "lost sys.stdin" in resolve console(Py3)

PostMon Dec 27, 2021 12:41 am

Hi,
I wrote a Python 3 based script that uses input() method to get user input from the console. However, when I run this script from the Resolve console window, I get the lost sys.stdin error. The same code works fine in pycharm. To verify this is a console-specific error, I just wrote the following code snippet in the console. I am still getting the same error.

Code: Select all
Py3> some_var = input("Enter some value")
Traceback (most recent call last):
  File "<nofile>", line 1, in <module>
RuntimeError: input(): lost sys.stdin


My environment details:
Windows 10 Pro, OS Build: 19044.1415
Resolve Studio: 17.4.2 build 9
Python runtime: 3.6.8 64bit

Any pointer to troubleshoot this is welcome.

Thanks,
Raja
Offline

raja1975

  • Posts: 6
  • Joined: Mon Dec 27, 2021 12:23 am
  • Real Name: Raja Ranjan Senapati

Re: input method throws "lost sys.stdin" in resolve console(

PostThu Dec 30, 2021 6:59 am

Answering my question with a workaround:
It appears the Resolve console window does not support stdin, since it is GUI-based. As a workaround, I wrote a wrapper on top of turtle as well as system stdin. This works seamlessly in a terminal as well as Resolve console GUI window :-)

Here's my implementation, in case someone encounters the same issue:
Code: Select all
import sys
import turtle

def safe_input(input_message):
    if not sys.stdin:
        sc = turtle.Screen(); #access turtle screen
        sc.setup(0, 0); # change the screen size to zero
        return turtle.textinput("Your App Title", input_message); #prompt the user with an input dialog
    return input(str);

# Now switch call to input() with safe_input()
#this will use system.stdin where available, or else will switch to turtle.
some_var = safe_input('enter your input value');



The other workaround is to use Fusion UI manager and move away from the console altogether.

Return to Software Developers

Who is online

Users browsing this forum: No registered users and 7 guests