Are you using it in standard python REPL? I think print etc. in Julia should work without any tricks. (Using PyJulia in Jupyter Notebook/Lab needs more improvements, though.)
What is your output when you evaluated the following?
>>> from julia import Main
>>> Main.eval("stdout")
<julia.core.PyIO object at 0x7f46f0075518>
>>> import sys
>>> sys.stdout
<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
(In case you are using Julia 0.6, it’s Main.eval("STDOUT").)
I was originally testing code on a Jupyter notebook. When I run Main.eval(“print(123)”) in the standard python REPL, the output does show up! However, even in the REPL, I still don’t see the results of Main.eval("""@benchmark x = 123""")
On the code you asked me to evaluate:
#####################################
# Evaluated on standard Python REPL #
#####################################
>>> from julia import Main
>>> Main.eval("stdout")
<julia.core.PyIO object at 0x7f46f0075518>
>>> import sys
>>> sys.stdout
<_io.TextIOWrapper name='<;stdout>' mode='w' encoding='UTF-8'>;
#################################
# Evaluated on Jupyter notebook #
#################################
from julia import Main
Main.eval("stdout")
<julia.core.PyIO at 0x7f0bf46a12b0>
import sys
sys.stdout
<ipykernel.iostream.OutStream at 0x7f0bf800dcc0>
I’m using Python 3.7.0, IPython 7.2.0, Julia 1.0.2, and the latest github master version of pyjulia (0.2.1.dev0)
I guess you saw <PyCall.jlwrap Trial(0.024 ns)> as below? This is because Julia REPL runs display on the returned value of the expression you type. In python REPL, you need to run it manually, like this: