I solved an analytic problem using sympy and saved everything in a .py file. When I run the code (which includes init_printing()) with ipython filename.py I get nice unicode output whenever I print within the file with pprint. So far so good.
When I import sympy in ipython qtconsole, I can get nice LaTeX outputs, just as stated in the documentation of sympy. But I get this nice printing only if the interactive console does the prining, i.e.:
Integral(sqrt(1/x), x)
produced a LaTeX image, while
pprint(Integral(sqrt(1/x), x))
does produce unicode output.
When running code from a file with
run filename.py
the only way I see to create output is to use pprint, i.e. I do not get the LaTeX output.
Does anyone see a solution? Thanks alot.
As in many case I think there is a confusion between returning an object (that trigger display hook) and displaying it. is is the same difference than
and
Both will "show" 1 if executed interactivly, but not in a script. In IPython you can see the difference with the Out[] prompt that appear or not depending of wether it is returned or displayed. I think in you case you need
from IPython.display import display_pretty
or maybe
from IPython.display import display_latex