Closed ywlds closed 2 years ago
Works for me:
julia> PyCall.py"print(\"Hello world\")"
Hello world
Are you running in a different environment, like a Jupyter notebook? You may have a problem from the fact that Python's stdio streams are not the same as Julia's, so they might not be captured by the notebook.
I can confirm that this does not work in a Jupyter notebook. Any workarounds?
It's just buffering. pyimport("sys").stdout.flush()
causes the output to appear in Jupyter.
We can do this automatically with
if isdefined(Main, :IJulia) && IJulia.inited
Main.IJulia.push_postexecute_hook(() -> pyimport("sys")."stdout"."flush"())
end
Maybe we should do this in PyCall's __init__
function?
Great, thanks!
The print function inside a python function when called by a julia function through PyCall seems not "print" anything at all? How can I fixed it, so that when used Julia and Python, we can debug more interactively?