I am wondering if there is a way to to interactively send text from a python script to qtconsole
.
The closest possible approach I found is through subprocess
, but it does not work. It follows the code that I tried:
import subprocess
QtConsole = subprocess.Popen(["jupyter", "qtconsole"], stdin=subprocess.PIPE)
QtConsole.wait()
QtConsole.stdin.write(("ls" + "\n").encode())
QtConsole.stdin.flush()
The qtconsole
open, but nothing is sent.
mypy
signal an Item "None" of "Optional[IO[bytes]]" has no attribute "write" [union-attr]
Error in the last two lines, which suggest me that no instances of Popen
are returned, and I am suspicious that the error may be there (but I don't know how to fix it).
If I remove the line QtConsole.wait()
nothing seems to happen.
I am using Python 3.10
.
I would like to have an interactive session with qtconsole
, therefore I am using Popen
instead of subprocess.run()
.
Any suggestions?