Python3 and pretty LaTeX printing

1,259 views
Skip to first unread message

andre...@web.de

unread,
Jul 21, 2013, 7:49:06 AM7/21/13
to sy...@googlegroups.com
Hi,

I played around with sympy in the ipython qtconsole and wanted to try out LaTeX pretty printing. I noticed that sympy does not produce pretty LaTeX formatted output when run with Python3. Python2 works perfectly:

------------------------------------------------

Python 3.3.2 (default, May 21 2013, 15:40:45)
*** snip ***
IPython 0.13.2 -- An enhanced Interactive Python.
*** snip ***

In [1]: from sympy import init_session

In [2]: init_session(quiet=True, use_latex=True)
IPython console for SymPy 0.7.3 (Python 3.3.2-64-bit) (ground types: python)

In [3]: init_printing(use_latex=True)

In [4]: Integral(sqrt(1/x),x)

Out[4]:
⌠          
⎮     ___  
⎮    ╱ 1   
⎮   ╱  ─  dx
⎮ ╲╱   x   


------------------------------------------------

Python 2.7.5 (default, May 12 2013, 12:00:47)
*** snip ***
IPython 0.13.2 -- An enhanced Interactive Python.
*** snip ***

In [1]: from sympy import init_session

In [2]: init_session(quiet=True, use_latex=True)
IPython console for SymPy 0.7.3 (Python 2.7.5-64-bit) (ground types: python)

In [3]: init_printing(use_latex=True)

In [4]: Integral(sqrt(1/x),x)

Out[4]: *** Beautiful LaTeX output ***

------------------------------------------------

Installed packages (Arch Linux):
    ipython 0.13.2-1
    ipython2 0.13.2-2

    python 3.3.2-1
    python-beaker 1.6.4-1
    python-cairo 1.10.0-2
    python-dbus 1.2.0-1
    python-dbus-common 1.2.0-1
    python-distribute 0.6.45-1
    python-gobject 3.8.3-1
    python-gobject2 2.28.6-9
    python-mako 0.8.1-1
    python-markupsafe 0.18-1
    python-numexpr 2.1-1
    python-numpy 1.7.1-1
    python-pygments 1.6-1
    python-pyqt4 4.10.2-2
    python-pytables 3.0.0-3
    python-pyudev 0.16.1-2
    python-pyzmq 13.1.0-1
    python-requests 1.2.3-2
    python-scipy 0.12.0-1
    python-sip 4.14.7-1
    python-sympy 0.7.3-1
    python-urwid 1.1.1-1
    python-xdg 0.25-1

    python2 2.7.5-1
    python2-apptools 4.2.0-1
    python2-beaker 1.6.4-1
    python2-cairo 1.10.0-1
    python2-configobj 4.7.2-6
    python2-dbus 1.2.0-1
    python2-distribute 0.6.45-1
    python2-envisage 4.3.0-1
    python2-gobject 3.8.3-1
    python2-gobject2 2.28.6-9
    python2-mako 0.8.1-1
    python2-markupsafe 0.18-1
    python2-notify 0.1.1-12
    python2-numexpr 2.1-1
    python2-numpy 1.7.1-1
    python2-pycurl 7.19.0-2
    python2-pyface 4.3.0-1
    python2-pygments 1.6-1
    python2-pyqt4 4.10.2-2
    python2-pytables 3.0.0-3
    python2-pyudev 0.16.1-2
    python2-pyzmq 13.1.0-1
    python2-sip 4.14.7-1
    python2-sympy 0.7.3-1
    python2-traits 4.3.0-1
    python2-traitsui 4.3.0-1
    python2-urwid 1.1.1-1

------------------------------------------------

Is this a known problem (a Google search didn't turn up anything)? Am I missing a package (though I should have all required packages)? Is it maybe a problem with the Arch Linux package that I should report downstream?

Thank you in advance,
            Andy

Aaron Meurer

unread,
Jul 21, 2013, 2:54:06 PM7/21/13
to sy...@googlegroups.com
It might be a bug, or it might be broken somehow on your machine. I
can't reproduce this right now because I don't have Python 3 versions
of all the libraries needed to run IPython in Python 3.

Can you see if preview(Integral(sqrt(1/x), x), output='png',
viewer='file', filename='test.png') works for you? It should create a
file called test.png in your current directory.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sympy+un...@googlegroups.com.
> To post to this group, send email to sy...@googlegroups.com.
> Visit this group at http://groups.google.com/group/sympy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

andre...@web.de

unread,
Jul 21, 2013, 5:29:53 PM7/21/13
to sy...@googlegroups.com
This input works for Python3 and Python2. The png file is created properly and bit-for-bit identical for both versions.

andre...@web.de

unread,
Jul 21, 2013, 5:47:40 PM7/21/13
to sy...@googlegroups.com
I also tried turning on the debug mode (SYMPY_DEBUG=True ipython/ipython2 qtconsole). Aside from a UserWarning about gmpy/gmpy2 not being installed, there is no output indicating any problems.

Aaron Meurer

unread,
Aug 20, 2013, 9:57:38 PM8/20/13
to sy...@googlegroups.com
Sorry for not responding to this. I had been waiting for Continuum to
build PySide for Python 3 on Mac OS X so I could test it, but today,
playing around with the printing in the notebook, I came across the
same issue. The fix is at https://github.com/sympy/sympy/pull/2398.
Can you let me know if it fixes the issue for you?

And by the way, SYMPY_DEBUG currently doesn't print anything for the
printing, but I added some debug output at
https://github.com/sympy/sympy/pull/2397 (and by the way, other than
this and the warning about gmpy, the only code that uses debug that I
know of is the limit code and one of the integration algorithms).

Aaron Meurer
Reply all
Reply to author
Forward
0 new messages