daleroberts / itermplot

An awesome iTerm2 backend for Matplotlib, so you can plot directly in your terminal.
1.49k stars 51 forks source link

Test fails #17

Closed edwinhu closed 7 years ago

edwinhu commented 7 years ago

Thanks for being so responsive and fixing issues! I just wanted to point out a potential documentation issue in the README.md.

Test fails.

Note that it works if you use IPython (even 2!).

xxx@xxx:~$ echo $MPLBACKEND
module://itermplot
xxx@xxxx:~$ python
Python 2.7.5 (default, Jan  2 2014, 20:34:29)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.plot([1,2,3])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr1/opt/python2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 2810, in plot
    ax = gca()
  File "/usr1/opt/python2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 707, in gca
    ax =  gcf().gca(**kwargs)
  File "/usr1/opt/python2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 370, in gcf
    return figure()
  File "/usr1/opt/python2.7/lib/python2.7/site-packages/matplotlib/pyplot.py", line 343, in figure
    **kwargs)
  File "/usr1/opt/python2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 79, in new_figure_manager
    return new_figure_manager_given_figure(num, figure)
  File "/usr1/opt/python2.7/lib/python2.7/site-packages/matplotlib/backends/backend_tkagg.py", line 87, in new_figure_manager_given_figure
    window = Tk.Tk()
  File "/usr1/opt/python2.7/lib/python2.7/lib-tk/Tkinter.py", line 1745, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
>>>
Python 2.7.11 |Anaconda custom (64-bit)| (default, Jun 15 2016, 15:21:30)
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import matplotlib.pyplot as plt

In [2]: plt.plot([1,2,3])
Out[2]: [<matplotlib.lines.Line2D at 0x7f4bfa9b9ad0>]

In [3]: plt.show()
# Success!
daleroberts commented 7 years ago

Hi, do you know what version of matplotlib you are using in the first example? It seems that matplotlib is ignoring the MPLBACKEND environment variable and is trying to load the tkagg backend.

edwinhu commented 7 years ago

Sorry for the late reply.

In [2]: matplotlib.__version__
Out[2]: '2.0.0'