Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise an error if matplotlib and latex are not installed when trying to render a png #9962

Closed
moorepants opened this issue Oct 5, 2015 · 6 comments

Comments

@moorepants
Copy link
Member

If you enable printing in qtconsole or ipython notebook and you have neither matplotlib or latex (or mathjax) installed you'll get empty pngs, e.g.:

ipython_011

from IPython.lib.latextools import latex_to_png doesn't seem to raise and error if neither are available.

@moorepants moorepants changed the title Raise and error if matplotlib and latex are not installed when trying to render a png Raise an error if matplotlib and latex are not installed when trying to render a png Oct 5, 2015
@moorepants
Copy link
Member Author

Maybe this should be: print using string or pretty printing if they are not installed.

@jksuom
Copy link
Member

jksuom commented Oct 5, 2015

notebook: Newer versions of notebook load MathJax from the net. It does not matter if neither matplotlib nor latex is available. It will suffice to provide IPython with a latex representation of the output.

qtconsole: If matplotlib and latex are not installed, png-data won't be available. If a latex string is provided, qtconsole will then try to use matplotlib. It will not fall back to pretty printing after getting None. (I think this is a bug.)

So it seems that, if matplotlib and latex are not installed, we should provide notebook with a latex string but let qtconsole only have the (pretty) string. However, there is a problem. Quoting from this thread:

We do our best in IPython prevent the kernel from knowing to which kind of frontend is connected, and actually you can even have a kernel connected to differents frontend at the same time.

This leaves the question: which (common) default should be chosen for notebook and qtconsole when both matplotlib and latex are missing, use_latex='mathjax' or use_latex=False?

@moorepants
Copy link
Member Author

notebook: Newer versions of notebook load MathJax from the net. It does not matter if neither matplotlib nor latex is available. It will suffice to provide IPython with a latex representation of the output.

I don't necessarily agree with this. I'd like it to "work" without an internet connection too.

qtconsole: If matplotlib and latex are not installed, png-data won't be available. If a latex string is provided, qtconsole will then try to use matplotlib. It will not fall back to pretty printing after getting None. (I think this is a bug.)

Agreed.

This leaves the question: which (common) default should be chosen for notebook and qtconsole when both matplotlib and latex are missing, use_latex='mathjax' or use_latex=False?

Maybe pretty print? But is it possible everything isn't installed for that to work too? Maybe it should just be the simple string rep.

@jksuom
Copy link
Member

jksuom commented Oct 5, 2015

I'd like it to "work" without an internet connection too.

I was just referring to how the designers of notebook seem to have planned it. An alternative is a local installation of MathJax. But that is big, of course...

As to the default, I think text/plain should perhaps be taken even if MathJax could give nicer output in notebook. Anyway, a notebook user will always have the option of running init_printing(use_latex='mathjax').

@jksuom
Copy link
Member

jksuom commented Oct 6, 2015

A possible plan for IPython notebook and qtconsole printing defaults (when use_latex=None).

  • If both latex and dvipng are available, set use_latex=True to enable png-formatting in SymPy.
  • Else if matplotlib is available, set use_latex='matplotlib' to enable png-formatting in IPython.
  • Else set use_latex=False to fall back to text/plain-formatting in SymPy. (Always configured, pretty by default. Custom pretty_printer can be set.)

These defaults may always be overridden by setting use_latex. For example, notebook users can choose mathjax.

@asmeurer
Copy link
Member

asmeurer commented Feb 4, 2016

The upstream bug in the qtconsole has been fixed. See also the related jupyter/qtconsole#95.

@asmeurer asmeurer closed this as completed Feb 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants