You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@zeppelin.apache.org by Xi Shen <da...@gmail.com> on 2016/09/13 08:56:13 UTC

Matplotlib uses tkinter instead of Agg

Hi,

I want to build a Zeppelin docker image for my self. The docker image is
based on ubuntu:wily, and has openjdk-8-jre and python3 installed. I also
installed other packages that I need.

After started Zeppelin in the docker, I am able to access the webapp from
my local browser. I tried to execute some simple Python script, and it
works fine. But when I try to run the matplotlib example, I got error
saying that tkinter cannot find the $DISPLAY.

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py", line
535, in figure
**kwargs)
File
"/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
line 84, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File
"/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
line 92, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive,
wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

Some people on the Internet suggested adding matplotlib.use('Agg') at the
beginning of the notebook, but it still does not work for me.

-- 


Thanks,
David S.

Re: Matplotlib uses tkinter instead of Agg

Posted by Xi Shen <da...@gmail.com>.
Please check my previous reply.

On Fri, Sep 16, 2016, 20:11 afancy <gr...@gmail.com> wrote:

> Hi,
>
> Has this problem been solved? I also encountered the same problem (see the
> following). I build from the source pulled from the Master branch.
>
> /afancy
>
> %python plt.figure() plt.plot(x, f(x), lw=2) z.show(plt, width='500px')
> plt.close()
>
> raceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
> figure
> **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 79, in new_figure_manager
> return new_figure_manager_given_figure(num, figure)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 87, in new_figure_manager_given_figure
> window = Tk.Tk()
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive,
> wantobjects, useTk, sync, use)
> _tkinter.TclError: no display name and no $DISPLAY environment variable
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2980, in
> plot
> ax = gca()
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 803, in gca
> ax = gcf().gca(**kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf
> return figure()
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
> figure
> **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 79, in new_figure_manager
> return new_figure_manager_given_figure(num, figure)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 87, in new_figure_manager_given_figure
> window = Tk.Tk()
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive,
> wantobjects, useTk, sync, use)
> _tkinter.TclError: no display name and no $DISPLAY environment variable
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "<stdin>", line 22, in show
> File "<stdin>", line 63, in show_matplotlib
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 560, in
> savefig
> fig = gcf()
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf
> return figure()
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
> figure
> **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 79, in new_figure_manager
> return new_figure_manager_given_figure(num, figure)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 87, in new_figure_manager_given_figure
> window = Tk.Tk()
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive,
> wantobjects, useTk, sync, use)
> _tkinter.TclError: no display name and no $DISPLAY environment variable
>
> On Thu, Sep 15, 2016 at 3:16 AM, Xi Shen <da...@gmail.com> wrote:
>
>> I think I found the cause. I think it is font problem. In docker
>> environment, it only has a small set of fonts installed. But I have not
>> find out which font should I install...I will update you guys later.
>>
>> On Thu, Sep 15, 2016, 00:33 moon soo Lee <mo...@apache.org> wrote:
>>
>>> Tried x = np.arange(100), x = np.linspace(-2,2,1000) with both python2
>>> and python3 in %python interpreter. I don't have any problem.
>>>
>>>
>>> On Wed, Sep 14, 2016 at 3:12 AM Xi Shen <da...@gmail.com> wrote:
>>>
>>>> OK, for this problem, it is discussed at
>>>> https://stackoverflow.com/questions/15538099/conversion-of-unicode-minus-sign-from-matplotlib-ticklabels
>>>>
>>>> However, I just tried with Jupyter notebook, and its matplotlib can
>>>> plot with negative values on the axes correctly, and
>>>> matplotlib.rcParams['axes.unicode_minus'] = True.
>>>>
>>>> Can you guys please check if this only happens to a Python3
>>>> environment? I don't think I am the first one hit this problem.
>>>>
>>>>
>>>>
>>>> On Wed, Sep 14, 2016 at 5:49 PM Xi Shen <da...@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I worked it out...So I have start a new instance of
>>>>> Zeppelin...creating a new notebook wont take effect...So all the Python
>>>>> code are executed in one python vm? Shouldn't separating ones are better?
>>>>>
>>>>> After I get matplotlib work, I have a new problem.
>>>>>
>>>>> This code snippet works
>>>>> %python
>>>>>
>>>>> import numpy as np
>>>>> import matplotlib.pyplot as plt
>>>>>
>>>>> x = np.arange(100)
>>>>>
>>>>> plt.figure()
>>>>> plt.plot(x, x**2)
>>>>> z.show(plt, width='300px')
>>>>> plt.close()
>>>>>
>>>>> But if I change x value to x= np.linspace(-2, 2, 1000), as it it used
>>>>> in the example, I got
>>>>>
>>>>> <matplotlib.figure.Figure object at 0x7fa177d197b8>
>>>>> [<matplotlib.lines.Line2D object at 0x7fa177ecf080>]
>>>>>
>>>>> Traceback (most recent call last):
>>>>> File "<stdin>", line 1, in <module>
>>>>> File "<stdin>", line 23, in show
>>>>> File "<stdin>", line 69, in show_matplotlib
>>>>> UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in
>>>>> position 17262: ordinal not in range(128)
>>>>>
>>>>> I did some testing, and I found if any of the value passed to plot()
>>>>> contains negative numbers, I will get this error...very odd.
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Sep 14, 2016 at 8:50 AM Felix Cheung <
>>>>> felixcheung_m@hotmail.com> wrote:
>>>>>
>>>>>> And
>>>>>> matplotlib.use('Agg')
>>>>>>
>>>>>> Would only work before matplotlib is first used so you would need to
>>>>>> restart the interpreter. From error stack below it looks like something
>>>>>> might be setting the default backend in matplotlib to TkAgg though.
>>>>>>
>>>>>> Are you using the Python interpreter or PySpark interpreter? Also how
>>>>>> you are calling matplotlib like Moon asks?
>>>>>>
>>>>>> _____________________________
>>>>>> From: moon soo Lee <mo...@apache.org>
>>>>>> Sent: Tuesday, September 13, 2016 2:34 PM
>>>>>> Subject: Re: Matplotlib uses tkinter instead of Agg
>>>>>> To: <us...@zeppelin.apache.org>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Thanks for sharing the problem.
>>>>>> Could you share which version of Zeppelin are you using and how did
>>>>>> you try matplotlib inside of Zeppelin? Are you trying matplotlib
>>>>>> with z.show() ?
>>>>>>
>>>>>> Thanks,
>>>>>> moon
>>>>>>
>>>>>> On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I want to build a Zeppelin docker image for my self. The docker
>>>>>>> image is based on ubuntu:wily, and has openjdk-8-jre and python3 installed.
>>>>>>> I also installed other packages that I need.
>>>>>>>
>>>>>>> After started Zeppelin in the docker, I am able to access the webapp
>>>>>>> from my local browser. I tried to execute some simple Python script, and it
>>>>>>> works fine. But when I try to run the matplotlib example, I got error
>>>>>>> saying that tkinter cannot find the $DISPLAY.
>>>>>>>
>>>>>>> Traceback (most recent call last):
>>>>>>> File "<stdin>", line 1, in <module>
>>>>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py",
>>>>>>> line 535, in figure
>>>>>>> **kwargs)
>>>>>>> File
>>>>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>>> line 84, in new_figure_manager
>>>>>>> return new_figure_manager_given_figure(num, figure)
>>>>>>> File
>>>>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>>> line 92, in new_figure_manager_given_figure
>>>>>>> window = Tk.Tk()
>>>>>>> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in __init__
>>>>>>> self.tk = _tkinter.create(screenName, baseName, className,
>>>>>>> interactive, wantobjects, useTk, sync, use)
>>>>>>> _tkinter.TclError: no display name and no $DISPLAY environment
>>>>>>> variable
>>>>>>>
>>>>>>> Some people on the Internet suggested adding matplotlib.use('Agg')
>>>>>>> at the beginning of the notebook, but it still does not work for me.
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>> David S.
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>
>>>>>
>>>>> Thanks,
>>>>> David S.
>>>>>
>>>> --
>>>>
>>>>
>>>> Thanks,
>>>> David S.
>>>>
>>> --
>>
>>
>> Thanks,
>> David S.
>>
>
> --


Thanks,
David S.

Re: Matplotlib uses tkinter instead of Agg

Posted by Xi Shen <da...@gmail.com>.
Hi,

Finally I worked it out. It is the LANG environment setting is not set in a
Ubuntu docker environment. In non-docker environment, LANG is by default
set to "en_US.UTF-8". I have to add an extra command to set the value in
the docker before starting zeppelin instance.

If you are interested, you may take a look at
https://hub.docker.com/r/davidshen84/zeppelin/


On Sat, Sep 17, 2016 at 6:01 PM Xi Shen <da...@gmail.com> wrote:

> I think it has nothing to do with docker. It relates to the matploblib
> settings. I don't know why, but in some other cases, I found matplotlib
> will use Agg as the backend by default.
>
> To solve your problem, just make sure you run this as the first thing when
> you start your Zeppelin environment.
>
> %python
>
> import matplotlib
> matplotlib.use('Agg')
>
>
>
> On Sat, Sep 17, 2016 at 4:27 PM afancy <gr...@gmail.com> wrote:
>
>> But, mine is not in docker environment.
>>
>> afancy
>>
>> On Fri, Sep 16, 2016 at 2:10 PM, afancy <gr...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> Has this problem been solved? I also encountered the same problem (see
>>> the following). I build from the source pulled from the Master branch.
>>>
>>> /afancy
>>>
>>> %python plt.figure() plt.plot(x, f(x), lw=2) z.show(plt, width='500px')
>>> plt.close()
>>>
>>> raceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
>>> figure
>>> **kwargs)
>>> File
>>> "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line
>>> 79, in new_figure_manager
>>> return new_figure_manager_given_figure(num, figure)
>>> File
>>> "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line
>>> 87, in new_figure_manager_given_figure
>>> window = Tk.Tk()
>>> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
>>> self.tk = _tkinter.create(screenName, baseName, className, interactive,
>>> wantobjects, useTk, sync, use)
>>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2980, in
>>> plot
>>> ax = gca()
>>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 803, in
>>> gca
>>> ax = gcf().gca(**kwargs)
>>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in
>>> gcf
>>> return figure()
>>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
>>> figure
>>> **kwargs)
>>> File
>>> "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line
>>> 79, in new_figure_manager
>>> return new_figure_manager_given_figure(num, figure)
>>> File
>>> "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line
>>> 87, in new_figure_manager_given_figure
>>> window = Tk.Tk()
>>> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
>>> self.tk = _tkinter.create(screenName, baseName, className, interactive,
>>> wantobjects, useTk, sync, use)
>>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> File "<stdin>", line 22, in show
>>> File "<stdin>", line 63, in show_matplotlib
>>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 560, in
>>> savefig
>>> fig = gcf()
>>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in
>>> gcf
>>> return figure()
>>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
>>> figure
>>> **kwargs)
>>> File
>>> "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line
>>> 79, in new_figure_manager
>>> return new_figure_manager_given_figure(num, figure)
>>> File
>>> "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line
>>> 87, in new_figure_manager_given_figure
>>> window = Tk.Tk()
>>> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
>>> self.tk = _tkinter.create(screenName, baseName, className, interactive,
>>> wantobjects, useTk, sync, use)
>>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>>>
>>> On Thu, Sep 15, 2016 at 3:16 AM, Xi Shen <da...@gmail.com> wrote:
>>>
>>>> I think I found the cause. I think it is font problem. In docker
>>>> environment, it only has a small set of fonts installed. But I have not
>>>> find out which font should I install...I will update you guys later.
>>>>
>>>> On Thu, Sep 15, 2016, 00:33 moon soo Lee <mo...@apache.org> wrote:
>>>>
>>>>> Tried x = np.arange(100), x = np.linspace(-2,2,1000) with both python2
>>>>> and python3 in %python interpreter. I don't have any problem.
>>>>>
>>>>>
>>>>> On Wed, Sep 14, 2016 at 3:12 AM Xi Shen <da...@gmail.com> wrote:
>>>>>
>>>>>> OK, for this problem, it is discussed at
>>>>>> https://stackoverflow.com/questions/15538099/conversion-of-unicode-minus-sign-from-matplotlib-ticklabels
>>>>>>
>>>>>> However, I just tried with Jupyter notebook, and its matplotlib can
>>>>>> plot with negative values on the axes correctly, and
>>>>>> matplotlib.rcParams['axes.unicode_minus'] = True.
>>>>>>
>>>>>> Can you guys please check if this only happens to a Python3
>>>>>> environment? I don't think I am the first one hit this problem.
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Sep 14, 2016 at 5:49 PM Xi Shen <da...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I worked it out...So I have start a new instance of
>>>>>>> Zeppelin...creating a new notebook wont take effect...So all the Python
>>>>>>> code are executed in one python vm? Shouldn't separating ones are better?
>>>>>>>
>>>>>>> After I get matplotlib work, I have a new problem.
>>>>>>>
>>>>>>> This code snippet works
>>>>>>> %python
>>>>>>>
>>>>>>> import numpy as np
>>>>>>> import matplotlib.pyplot as plt
>>>>>>>
>>>>>>> x = np.arange(100)
>>>>>>>
>>>>>>> plt.figure()
>>>>>>> plt.plot(x, x**2)
>>>>>>> z.show(plt, width='300px')
>>>>>>> plt.close()
>>>>>>>
>>>>>>> But if I change x value to x= np.linspace(-2, 2, 1000), as it it
>>>>>>> used in the example, I got
>>>>>>>
>>>>>>> <matplotlib.figure.Figure object at 0x7fa177d197b8>
>>>>>>> [<matplotlib.lines.Line2D object at 0x7fa177ecf080>]
>>>>>>>
>>>>>>> Traceback (most recent call last):
>>>>>>> File "<stdin>", line 1, in <module>
>>>>>>> File "<stdin>", line 23, in show
>>>>>>> File "<stdin>", line 69, in show_matplotlib
>>>>>>> UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in
>>>>>>> position 17262: ordinal not in range(128)
>>>>>>>
>>>>>>> I did some testing, and I found if any of the value passed to plot()
>>>>>>> contains negative numbers, I will get this error...very odd.
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Wed, Sep 14, 2016 at 8:50 AM Felix Cheung <
>>>>>>> felixcheung_m@hotmail.com> wrote:
>>>>>>>
>>>>>>>> And
>>>>>>>> matplotlib.use('Agg')
>>>>>>>>
>>>>>>>> Would only work before matplotlib is first used so you would need
>>>>>>>> to restart the interpreter. From error stack below it looks like something
>>>>>>>> might be setting the default backend in matplotlib to TkAgg though.
>>>>>>>>
>>>>>>>> Are you using the Python interpreter or PySpark interpreter? Also
>>>>>>>> how you are calling matplotlib like Moon asks?
>>>>>>>>
>>>>>>>> _____________________________
>>>>>>>> From: moon soo Lee <mo...@apache.org>
>>>>>>>> Sent: Tuesday, September 13, 2016 2:34 PM
>>>>>>>> Subject: Re: Matplotlib uses tkinter instead of Agg
>>>>>>>> To: <us...@zeppelin.apache.org>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> Thanks for sharing the problem.
>>>>>>>> Could you share which version of Zeppelin are you using and how did
>>>>>>>> you try matplotlib inside of Zeppelin? Are you trying matplotlib
>>>>>>>> with z.show() ?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> moon
>>>>>>>>
>>>>>>>> On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I want to build a Zeppelin docker image for my self. The docker
>>>>>>>>> image is based on ubuntu:wily, and has openjdk-8-jre and python3 installed.
>>>>>>>>> I also installed other packages that I need.
>>>>>>>>>
>>>>>>>>> After started Zeppelin in the docker, I am able to access the
>>>>>>>>> webapp from my local browser. I tried to execute some simple Python script,
>>>>>>>>> and it works fine. But when I try to run the matplotlib example, I got
>>>>>>>>> error saying that tkinter cannot find the $DISPLAY.
>>>>>>>>>
>>>>>>>>> Traceback (most recent call last):
>>>>>>>>> File "<stdin>", line 1, in <module>
>>>>>>>>> File
>>>>>>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py", line 535, in
>>>>>>>>> figure
>>>>>>>>> **kwargs)
>>>>>>>>> File
>>>>>>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>>>>> line 84, in new_figure_manager
>>>>>>>>> return new_figure_manager_given_figure(num, figure)
>>>>>>>>> File
>>>>>>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>>>>> line 92, in new_figure_manager_given_figure
>>>>>>>>> window = Tk.Tk()
>>>>>>>>> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in
>>>>>>>>> __init__
>>>>>>>>> self.tk = _tkinter.create(screenName, baseName, className,
>>>>>>>>> interactive, wantobjects, useTk, sync, use)
>>>>>>>>> _tkinter.TclError: no display name and no $DISPLAY environment
>>>>>>>>> variable
>>>>>>>>>
>>>>>>>>> Some people on the Internet suggested adding matplotlib.use('Agg')
>>>>>>>>> at the beginning of the notebook, but it still does not work for me.
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Thanks,
>>>>>>>>> David S.
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>> David S.
>>>>>>>
>>>>>> --
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> David S.
>>>>>>
>>>>> --
>>>>
>>>>
>>>> Thanks,
>>>> David S.
>>>>
>>>
>>>
>> --
>
>
> Thanks,
> David S.
>
-- 


Thanks,
David S.

Re: Matplotlib uses tkinter instead of Agg

Posted by Xi Shen <da...@gmail.com>.
I think it has nothing to do with docker. It relates to the matploblib
settings. I don't know why, but in some other cases, I found matplotlib
will use Agg as the backend by default.

To solve your problem, just make sure you run this as the first thing when
you start your Zeppelin environment.

%python

import matplotlib
matplotlib.use('Agg')



On Sat, Sep 17, 2016 at 4:27 PM afancy <gr...@gmail.com> wrote:

> But, mine is not in docker environment.
>
> afancy
>
> On Fri, Sep 16, 2016 at 2:10 PM, afancy <gr...@gmail.com> wrote:
>
>> Hi,
>>
>> Has this problem been solved? I also encountered the same problem (see
>> the following). I build from the source pulled from the Master branch.
>>
>> /afancy
>>
>> %python plt.figure() plt.plot(x, f(x), lw=2) z.show(plt, width='500px')
>> plt.close()
>>
>> raceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
>> figure
>> **kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
>> line 79, in new_figure_manager
>> return new_figure_manager_given_figure(num, figure)
>> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
>> line 87, in new_figure_manager_given_figure
>> window = Tk.Tk()
>> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
>> self.tk = _tkinter.create(screenName, baseName, className, interactive,
>> wantobjects, useTk, sync, use)
>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2980, in
>> plot
>> ax = gca()
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 803, in gca
>> ax = gcf().gca(**kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf
>> return figure()
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
>> figure
>> **kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
>> line 79, in new_figure_manager
>> return new_figure_manager_given_figure(num, figure)
>> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
>> line 87, in new_figure_manager_given_figure
>> window = Tk.Tk()
>> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
>> self.tk = _tkinter.create(screenName, baseName, className, interactive,
>> wantobjects, useTk, sync, use)
>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "<stdin>", line 22, in show
>> File "<stdin>", line 63, in show_matplotlib
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 560, in
>> savefig
>> fig = gcf()
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf
>> return figure()
>> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
>> figure
>> **kwargs)
>> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
>> line 79, in new_figure_manager
>> return new_figure_manager_given_figure(num, figure)
>> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
>> line 87, in new_figure_manager_given_figure
>> window = Tk.Tk()
>> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
>> self.tk = _tkinter.create(screenName, baseName, className, interactive,
>> wantobjects, useTk, sync, use)
>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>>
>> On Thu, Sep 15, 2016 at 3:16 AM, Xi Shen <da...@gmail.com> wrote:
>>
>>> I think I found the cause. I think it is font problem. In docker
>>> environment, it only has a small set of fonts installed. But I have not
>>> find out which font should I install...I will update you guys later.
>>>
>>> On Thu, Sep 15, 2016, 00:33 moon soo Lee <mo...@apache.org> wrote:
>>>
>>>> Tried x = np.arange(100), x = np.linspace(-2,2,1000) with both python2
>>>> and python3 in %python interpreter. I don't have any problem.
>>>>
>>>>
>>>> On Wed, Sep 14, 2016 at 3:12 AM Xi Shen <da...@gmail.com> wrote:
>>>>
>>>>> OK, for this problem, it is discussed at
>>>>> https://stackoverflow.com/questions/15538099/conversion-of-unicode-minus-sign-from-matplotlib-ticklabels
>>>>>
>>>>> However, I just tried with Jupyter notebook, and its matplotlib can
>>>>> plot with negative values on the axes correctly, and
>>>>> matplotlib.rcParams['axes.unicode_minus'] = True.
>>>>>
>>>>> Can you guys please check if this only happens to a Python3
>>>>> environment? I don't think I am the first one hit this problem.
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Sep 14, 2016 at 5:49 PM Xi Shen <da...@gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I worked it out...So I have start a new instance of
>>>>>> Zeppelin...creating a new notebook wont take effect...So all the Python
>>>>>> code are executed in one python vm? Shouldn't separating ones are better?
>>>>>>
>>>>>> After I get matplotlib work, I have a new problem.
>>>>>>
>>>>>> This code snippet works
>>>>>> %python
>>>>>>
>>>>>> import numpy as np
>>>>>> import matplotlib.pyplot as plt
>>>>>>
>>>>>> x = np.arange(100)
>>>>>>
>>>>>> plt.figure()
>>>>>> plt.plot(x, x**2)
>>>>>> z.show(plt, width='300px')
>>>>>> plt.close()
>>>>>>
>>>>>> But if I change x value to x= np.linspace(-2, 2, 1000), as it it used
>>>>>> in the example, I got
>>>>>>
>>>>>> <matplotlib.figure.Figure object at 0x7fa177d197b8>
>>>>>> [<matplotlib.lines.Line2D object at 0x7fa177ecf080>]
>>>>>>
>>>>>> Traceback (most recent call last):
>>>>>> File "<stdin>", line 1, in <module>
>>>>>> File "<stdin>", line 23, in show
>>>>>> File "<stdin>", line 69, in show_matplotlib
>>>>>> UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in
>>>>>> position 17262: ordinal not in range(128)
>>>>>>
>>>>>> I did some testing, and I found if any of the value passed to plot()
>>>>>> contains negative numbers, I will get this error...very odd.
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Wed, Sep 14, 2016 at 8:50 AM Felix Cheung <
>>>>>> felixcheung_m@hotmail.com> wrote:
>>>>>>
>>>>>>> And
>>>>>>> matplotlib.use('Agg')
>>>>>>>
>>>>>>> Would only work before matplotlib is first used so you would need to
>>>>>>> restart the interpreter. From error stack below it looks like something
>>>>>>> might be setting the default backend in matplotlib to TkAgg though.
>>>>>>>
>>>>>>> Are you using the Python interpreter or PySpark interpreter? Also
>>>>>>> how you are calling matplotlib like Moon asks?
>>>>>>>
>>>>>>> _____________________________
>>>>>>> From: moon soo Lee <mo...@apache.org>
>>>>>>> Sent: Tuesday, September 13, 2016 2:34 PM
>>>>>>> Subject: Re: Matplotlib uses tkinter instead of Agg
>>>>>>> To: <us...@zeppelin.apache.org>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> Thanks for sharing the problem.
>>>>>>> Could you share which version of Zeppelin are you using and how did
>>>>>>> you try matplotlib inside of Zeppelin? Are you trying matplotlib
>>>>>>> with z.show() ?
>>>>>>>
>>>>>>> Thanks,
>>>>>>> moon
>>>>>>>
>>>>>>> On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I want to build a Zeppelin docker image for my self. The docker
>>>>>>>> image is based on ubuntu:wily, and has openjdk-8-jre and python3 installed.
>>>>>>>> I also installed other packages that I need.
>>>>>>>>
>>>>>>>> After started Zeppelin in the docker, I am able to access the
>>>>>>>> webapp from my local browser. I tried to execute some simple Python script,
>>>>>>>> and it works fine. But when I try to run the matplotlib example, I got
>>>>>>>> error saying that tkinter cannot find the $DISPLAY.
>>>>>>>>
>>>>>>>> Traceback (most recent call last):
>>>>>>>> File "<stdin>", line 1, in <module>
>>>>>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py",
>>>>>>>> line 535, in figure
>>>>>>>> **kwargs)
>>>>>>>> File
>>>>>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>>>> line 84, in new_figure_manager
>>>>>>>> return new_figure_manager_given_figure(num, figure)
>>>>>>>> File
>>>>>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>>>> line 92, in new_figure_manager_given_figure
>>>>>>>> window = Tk.Tk()
>>>>>>>> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in
>>>>>>>> __init__
>>>>>>>> self.tk = _tkinter.create(screenName, baseName, className,
>>>>>>>> interactive, wantobjects, useTk, sync, use)
>>>>>>>> _tkinter.TclError: no display name and no $DISPLAY environment
>>>>>>>> variable
>>>>>>>>
>>>>>>>> Some people on the Internet suggested adding matplotlib.use('Agg')
>>>>>>>> at the beginning of the notebook, but it still does not work for me.
>>>>>>>>
>>>>>>>> --
>>>>>>>>
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> David S.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> David S.
>>>>>>
>>>>> --
>>>>>
>>>>>
>>>>> Thanks,
>>>>> David S.
>>>>>
>>>> --
>>>
>>>
>>> Thanks,
>>> David S.
>>>
>>
>>
> --


Thanks,
David S.

Re: Matplotlib uses tkinter instead of Agg

Posted by afancy <gr...@gmail.com>.
But, mine is not in docker environment.

afancy

On Fri, Sep 16, 2016 at 2:10 PM, afancy <gr...@gmail.com> wrote:

> Hi,
>
> Has this problem been solved? I also encountered the same problem (see the
> following). I build from the source pulled from the Master branch.
>
> /afancy
>
> %python plt.figure() plt.plot(x, f(x), lw=2) z.show(plt, width='500px')
> plt.close()
>
> raceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
> figure
> **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 79, in new_figure_manager
> return new_figure_manager_given_figure(num, figure)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 87, in new_figure_manager_given_figure
> window = Tk.Tk()
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive,
> wantobjects, useTk, sync, use)
> _tkinter.TclError: no display name and no $DISPLAY environment variable
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2980, in
> plot
> ax = gca()
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 803, in gca
> ax = gcf().gca(**kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf
> return figure()
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
> figure
> **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 79, in new_figure_manager
> return new_figure_manager_given_figure(num, figure)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 87, in new_figure_manager_given_figure
> window = Tk.Tk()
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive,
> wantobjects, useTk, sync, use)
> _tkinter.TclError: no display name and no $DISPLAY environment variable
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "<stdin>", line 22, in show
> File "<stdin>", line 63, in show_matplotlib
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 560, in
> savefig
> fig = gcf()
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf
> return figure()
> File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
> figure
> **kwargs)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 79, in new_figure_manager
> return new_figure_manager_given_figure(num, figure)
> File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
> line 87, in new_figure_manager_given_figure
> window = Tk.Tk()
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive,
> wantobjects, useTk, sync, use)
> _tkinter.TclError: no display name and no $DISPLAY environment variable
>
> On Thu, Sep 15, 2016 at 3:16 AM, Xi Shen <da...@gmail.com> wrote:
>
>> I think I found the cause. I think it is font problem. In docker
>> environment, it only has a small set of fonts installed. But I have not
>> find out which font should I install...I will update you guys later.
>>
>> On Thu, Sep 15, 2016, 00:33 moon soo Lee <mo...@apache.org> wrote:
>>
>>> Tried x = np.arange(100), x = np.linspace(-2,2,1000) with both python2
>>> and python3 in %python interpreter. I don't have any problem.
>>>
>>>
>>> On Wed, Sep 14, 2016 at 3:12 AM Xi Shen <da...@gmail.com> wrote:
>>>
>>>> OK, for this problem, it is discussed at https://stackoverflow.com/q
>>>> uestions/15538099/conversion-of-unicode-minus-sign-from-matp
>>>> lotlib-ticklabels
>>>>
>>>> However, I just tried with Jupyter notebook, and its matplotlib can
>>>> plot with negative values on the axes correctly, and
>>>> matplotlib.rcParams['axes.unicode_minus'] = True.
>>>>
>>>> Can you guys please check if this only happens to a Python3
>>>> environment? I don't think I am the first one hit this problem.
>>>>
>>>>
>>>>
>>>> On Wed, Sep 14, 2016 at 5:49 PM Xi Shen <da...@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I worked it out...So I have start a new instance of
>>>>> Zeppelin...creating a new notebook wont take effect...So all the Python
>>>>> code are executed in one python vm? Shouldn't separating ones are better?
>>>>>
>>>>> After I get matplotlib work, I have a new problem.
>>>>>
>>>>> This code snippet works
>>>>> %python
>>>>>
>>>>> import numpy as np
>>>>> import matplotlib.pyplot as plt
>>>>>
>>>>> x = np.arange(100)
>>>>>
>>>>> plt.figure()
>>>>> plt.plot(x, x**2)
>>>>> z.show(plt, width='300px')
>>>>> plt.close()
>>>>>
>>>>> But if I change x value to x= np.linspace(-2, 2, 1000), as it it used
>>>>> in the example, I got
>>>>>
>>>>> <matplotlib.figure.Figure object at 0x7fa177d197b8>
>>>>> [<matplotlib.lines.Line2D object at 0x7fa177ecf080>]
>>>>>
>>>>> Traceback (most recent call last):
>>>>> File "<stdin>", line 1, in <module>
>>>>> File "<stdin>", line 23, in show
>>>>> File "<stdin>", line 69, in show_matplotlib
>>>>> UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in
>>>>> position 17262: ordinal not in range(128)
>>>>>
>>>>> I did some testing, and I found if any of the value passed to plot()
>>>>> contains negative numbers, I will get this error...very odd.
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Sep 14, 2016 at 8:50 AM Felix Cheung <
>>>>> felixcheung_m@hotmail.com> wrote:
>>>>>
>>>>>> And
>>>>>> matplotlib.use('Agg')
>>>>>>
>>>>>> Would only work before matplotlib is first used so you would need to
>>>>>> restart the interpreter. From error stack below it looks like something
>>>>>> might be setting the default backend in matplotlib to TkAgg though.
>>>>>>
>>>>>> Are you using the Python interpreter or PySpark interpreter? Also how
>>>>>> you are calling matplotlib like Moon asks?
>>>>>>
>>>>>> _____________________________
>>>>>> From: moon soo Lee <mo...@apache.org>
>>>>>> Sent: Tuesday, September 13, 2016 2:34 PM
>>>>>> Subject: Re: Matplotlib uses tkinter instead of Agg
>>>>>> To: <us...@zeppelin.apache.org>
>>>>>>
>>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Thanks for sharing the problem.
>>>>>> Could you share which version of Zeppelin are you using and how did
>>>>>> you try matplotlib inside of Zeppelin? Are you trying matplotlib
>>>>>> with z.show() ?
>>>>>>
>>>>>> Thanks,
>>>>>> moon
>>>>>>
>>>>>> On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> I want to build a Zeppelin docker image for my self. The docker
>>>>>>> image is based on ubuntu:wily, and has openjdk-8-jre and python3 installed.
>>>>>>> I also installed other packages that I need.
>>>>>>>
>>>>>>> After started Zeppelin in the docker, I am able to access the webapp
>>>>>>> from my local browser. I tried to execute some simple Python script, and it
>>>>>>> works fine. But when I try to run the matplotlib example, I got error
>>>>>>> saying that tkinter cannot find the $DISPLAY.
>>>>>>>
>>>>>>> Traceback (most recent call last):
>>>>>>> File "<stdin>", line 1, in <module>
>>>>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py",
>>>>>>> line 535, in figure
>>>>>>> **kwargs)
>>>>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>>> line 84, in new_figure_manager
>>>>>>> return new_figure_manager_given_figure(num, figure)
>>>>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>>> line 92, in new_figure_manager_given_figure
>>>>>>> window = Tk.Tk()
>>>>>>> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in
>>>>>>> __init__
>>>>>>> self.tk = _tkinter.create(screenName, baseName, className,
>>>>>>> interactive, wantobjects, useTk, sync, use)
>>>>>>> _tkinter.TclError: no display name and no $DISPLAY environment
>>>>>>> variable
>>>>>>>
>>>>>>> Some people on the Internet suggested adding matplotlib.use('Agg')
>>>>>>> at the beginning of the notebook, but it still does not work for me.
>>>>>>>
>>>>>>> --
>>>>>>>
>>>>>>>
>>>>>>> Thanks,
>>>>>>> David S.
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>
>>>>>
>>>>> Thanks,
>>>>> David S.
>>>>>
>>>> --
>>>>
>>>>
>>>> Thanks,
>>>> David S.
>>>>
>>> --
>>
>>
>> Thanks,
>> David S.
>>
>
>

Re: Matplotlib uses tkinter instead of Agg

Posted by afancy <gr...@gmail.com>.
Hi,

Has this problem been solved? I also encountered the same problem (see the
following). I build from the source pulled from the Master branch.

/afancy

%python plt.figure() plt.plot(x, f(x), lw=2) z.show(plt, width='500px')
plt.close()

raceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
line 79, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
line 87, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive,
wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 2980, in plot
ax = gca()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 803, in gca
ax = gcf().gca(**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf
return figure()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
line 79, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
line 87, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive,
wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 22, in show
File "<stdin>", line 63, in show_matplotlib
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 560, in
savefig
fig = gcf()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 450, in gcf
return figure()
File "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 423, in
figure
**kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
line 79, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py",
line 87, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1767, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive,
wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

On Thu, Sep 15, 2016 at 3:16 AM, Xi Shen <da...@gmail.com> wrote:

> I think I found the cause. I think it is font problem. In docker
> environment, it only has a small set of fonts installed. But I have not
> find out which font should I install...I will update you guys later.
>
> On Thu, Sep 15, 2016, 00:33 moon soo Lee <mo...@apache.org> wrote:
>
>> Tried x = np.arange(100), x = np.linspace(-2,2,1000) with both python2
>> and python3 in %python interpreter. I don't have any problem.
>>
>>
>> On Wed, Sep 14, 2016 at 3:12 AM Xi Shen <da...@gmail.com> wrote:
>>
>>> OK, for this problem, it is discussed at https://stackoverflow.com/
>>> questions/15538099/conversion-of-unicode-minus-sign-from-
>>> matplotlib-ticklabels
>>>
>>> However, I just tried with Jupyter notebook, and its matplotlib can plot
>>> with negative values on the axes correctly, and matplotlib.rcParams['axes.unicode_minus']
>>> = True.
>>>
>>> Can you guys please check if this only happens to a Python3 environment?
>>> I don't think I am the first one hit this problem.
>>>
>>>
>>>
>>> On Wed, Sep 14, 2016 at 5:49 PM Xi Shen <da...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I worked it out...So I have start a new instance of Zeppelin...creating
>>>> a new notebook wont take effect...So all the Python code are executed in
>>>> one python vm? Shouldn't separating ones are better?
>>>>
>>>> After I get matplotlib work, I have a new problem.
>>>>
>>>> This code snippet works
>>>> %python
>>>>
>>>> import numpy as np
>>>> import matplotlib.pyplot as plt
>>>>
>>>> x = np.arange(100)
>>>>
>>>> plt.figure()
>>>> plt.plot(x, x**2)
>>>> z.show(plt, width='300px')
>>>> plt.close()
>>>>
>>>> But if I change x value to x= np.linspace(-2, 2, 1000), as it it used
>>>> in the example, I got
>>>>
>>>> <matplotlib.figure.Figure object at 0x7fa177d197b8>
>>>> [<matplotlib.lines.Line2D object at 0x7fa177ecf080>]
>>>>
>>>> Traceback (most recent call last):
>>>> File "<stdin>", line 1, in <module>
>>>> File "<stdin>", line 23, in show
>>>> File "<stdin>", line 69, in show_matplotlib
>>>> UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in
>>>> position 17262: ordinal not in range(128)
>>>>
>>>> I did some testing, and I found if any of the value passed to plot()
>>>> contains negative numbers, I will get this error...very odd.
>>>>
>>>>
>>>>
>>>> On Wed, Sep 14, 2016 at 8:50 AM Felix Cheung <fe...@hotmail.com>
>>>> wrote:
>>>>
>>>>> And
>>>>> matplotlib.use('Agg')
>>>>>
>>>>> Would only work before matplotlib is first used so you would need to
>>>>> restart the interpreter. From error stack below it looks like something
>>>>> might be setting the default backend in matplotlib to TkAgg though.
>>>>>
>>>>> Are you using the Python interpreter or PySpark interpreter? Also how
>>>>> you are calling matplotlib like Moon asks?
>>>>>
>>>>> _____________________________
>>>>> From: moon soo Lee <mo...@apache.org>
>>>>> Sent: Tuesday, September 13, 2016 2:34 PM
>>>>> Subject: Re: Matplotlib uses tkinter instead of Agg
>>>>> To: <us...@zeppelin.apache.org>
>>>>>
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> Thanks for sharing the problem.
>>>>> Could you share which version of Zeppelin are you using and how did
>>>>> you try matplotlib inside of Zeppelin? Are you trying matplotlib with
>>>>> z.show() ?
>>>>>
>>>>> Thanks,
>>>>> moon
>>>>>
>>>>> On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I want to build a Zeppelin docker image for my self. The docker image
>>>>>> is based on ubuntu:wily, and has openjdk-8-jre and python3 installed. I
>>>>>> also installed other packages that I need.
>>>>>>
>>>>>> After started Zeppelin in the docker, I am able to access the webapp
>>>>>> from my local browser. I tried to execute some simple Python script, and it
>>>>>> works fine. But when I try to run the matplotlib example, I got error
>>>>>> saying that tkinter cannot find the $DISPLAY.
>>>>>>
>>>>>> Traceback (most recent call last):
>>>>>> File "<stdin>", line 1, in <module>
>>>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py",
>>>>>> line 535, in figure
>>>>>> **kwargs)
>>>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>> line 84, in new_figure_manager
>>>>>> return new_figure_manager_given_figure(num, figure)
>>>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>>> line 92, in new_figure_manager_given_figure
>>>>>> window = Tk.Tk()
>>>>>> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in __init__
>>>>>> self.tk = _tkinter.create(screenName, baseName, className,
>>>>>> interactive, wantobjects, useTk, sync, use)
>>>>>> _tkinter.TclError: no display name and no $DISPLAY environment
>>>>>> variable
>>>>>>
>>>>>> Some people on the Internet suggested adding matplotlib.use('Agg') at
>>>>>> the beginning of the notebook, but it still does not work for me.
>>>>>>
>>>>>> --
>>>>>>
>>>>>>
>>>>>> Thanks,
>>>>>> David S.
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>
>>>>
>>>> Thanks,
>>>> David S.
>>>>
>>> --
>>>
>>>
>>> Thanks,
>>> David S.
>>>
>> --
>
>
> Thanks,
> David S.
>

Re: Matplotlib uses tkinter instead of Agg

Posted by Xi Shen <da...@gmail.com>.
I think I found the cause. I think it is font problem. In docker
environment, it only has a small set of fonts installed. But I have not
find out which font should I install...I will update you guys later.

On Thu, Sep 15, 2016, 00:33 moon soo Lee <mo...@apache.org> wrote:

> Tried x = np.arange(100), x = np.linspace(-2,2,1000) with both python2 and
> python3 in %python interpreter. I don't have any problem.
>
>
> On Wed, Sep 14, 2016 at 3:12 AM Xi Shen <da...@gmail.com> wrote:
>
>> OK, for this problem, it is discussed at
>> https://stackoverflow.com/questions/15538099/conversion-of-unicode-minus-sign-from-matplotlib-ticklabels
>>
>> However, I just tried with Jupyter notebook, and its matplotlib can plot
>> with negative values on the axes correctly, and
>> matplotlib.rcParams['axes.unicode_minus'] = True.
>>
>> Can you guys please check if this only happens to a Python3 environment?
>> I don't think I am the first one hit this problem.
>>
>>
>>
>> On Wed, Sep 14, 2016 at 5:49 PM Xi Shen <da...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I worked it out...So I have start a new instance of Zeppelin...creating
>>> a new notebook wont take effect...So all the Python code are executed in
>>> one python vm? Shouldn't separating ones are better?
>>>
>>> After I get matplotlib work, I have a new problem.
>>>
>>> This code snippet works
>>> %python
>>>
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>>
>>> x = np.arange(100)
>>>
>>> plt.figure()
>>> plt.plot(x, x**2)
>>> z.show(plt, width='300px')
>>> plt.close()
>>>
>>> But if I change x value to x= np.linspace(-2, 2, 1000), as it it used in
>>> the example, I got
>>>
>>> <matplotlib.figure.Figure object at 0x7fa177d197b8>
>>> [<matplotlib.lines.Line2D object at 0x7fa177ecf080>]
>>>
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> File "<stdin>", line 23, in show
>>> File "<stdin>", line 69, in show_matplotlib
>>> UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in
>>> position 17262: ordinal not in range(128)
>>>
>>> I did some testing, and I found if any of the value passed to plot()
>>> contains negative numbers, I will get this error...very odd.
>>>
>>>
>>>
>>> On Wed, Sep 14, 2016 at 8:50 AM Felix Cheung <fe...@hotmail.com>
>>> wrote:
>>>
>>>> And
>>>> matplotlib.use('Agg')
>>>>
>>>> Would only work before matplotlib is first used so you would need to
>>>> restart the interpreter. From error stack below it looks like something
>>>> might be setting the default backend in matplotlib to TkAgg though.
>>>>
>>>> Are you using the Python interpreter or PySpark interpreter? Also how
>>>> you are calling matplotlib like Moon asks?
>>>>
>>>> _____________________________
>>>> From: moon soo Lee <mo...@apache.org>
>>>> Sent: Tuesday, September 13, 2016 2:34 PM
>>>> Subject: Re: Matplotlib uses tkinter instead of Agg
>>>> To: <us...@zeppelin.apache.org>
>>>>
>>>>
>>>>
>>>> Hi,
>>>>
>>>> Thanks for sharing the problem.
>>>> Could you share which version of Zeppelin are you using and how did you
>>>> try matplotlib inside of Zeppelin? Are you trying matplotlib with
>>>> z.show() ?
>>>>
>>>> Thanks,
>>>> moon
>>>>
>>>> On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> I want to build a Zeppelin docker image for my self. The docker image
>>>>> is based on ubuntu:wily, and has openjdk-8-jre and python3 installed. I
>>>>> also installed other packages that I need.
>>>>>
>>>>> After started Zeppelin in the docker, I am able to access the webapp
>>>>> from my local browser. I tried to execute some simple Python script, and it
>>>>> works fine. But when I try to run the matplotlib example, I got error
>>>>> saying that tkinter cannot find the $DISPLAY.
>>>>>
>>>>> Traceback (most recent call last):
>>>>> File "<stdin>", line 1, in <module>
>>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py",
>>>>> line 535, in figure
>>>>> **kwargs)
>>>>> File
>>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>> line 84, in new_figure_manager
>>>>> return new_figure_manager_given_figure(num, figure)
>>>>> File
>>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>>> line 92, in new_figure_manager_given_figure
>>>>> window = Tk.Tk()
>>>>> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in __init__
>>>>> self.tk = _tkinter.create(screenName, baseName, className,
>>>>> interactive, wantobjects, useTk, sync, use)
>>>>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>>>>>
>>>>> Some people on the Internet suggested adding matplotlib.use('Agg') at
>>>>> the beginning of the notebook, but it still does not work for me.
>>>>>
>>>>> --
>>>>>
>>>>>
>>>>> Thanks,
>>>>> David S.
>>>>>
>>>>
>>>>
>>>> --
>>>
>>>
>>> Thanks,
>>> David S.
>>>
>> --
>>
>>
>> Thanks,
>> David S.
>>
> --


Thanks,
David S.

Re: Matplotlib uses tkinter instead of Agg

Posted by moon soo Lee <mo...@apache.org>.
Tried x = np.arange(100), x = np.linspace(-2,2,1000) with both python2 and
python3 in %python interpreter. I don't have any problem.

On Wed, Sep 14, 2016 at 3:12 AM Xi Shen <da...@gmail.com> wrote:

> OK, for this problem, it is discussed at
> https://stackoverflow.com/questions/15538099/conversion-of-unicode-minus-sign-from-matplotlib-ticklabels
>
> However, I just tried with Jupyter notebook, and its matplotlib can plot
> with negative values on the axes correctly, and
> matplotlib.rcParams['axes.unicode_minus'] = True.
>
> Can you guys please check if this only happens to a Python3 environment? I
> don't think I am the first one hit this problem.
>
>
>
> On Wed, Sep 14, 2016 at 5:49 PM Xi Shen <da...@gmail.com> wrote:
>
>> Hi,
>>
>> I worked it out...So I have start a new instance of Zeppelin...creating a
>> new notebook wont take effect...So all the Python code are executed in one
>> python vm? Shouldn't separating ones are better?
>>
>> After I get matplotlib work, I have a new problem.
>>
>> This code snippet works
>> %python
>>
>> import numpy as np
>> import matplotlib.pyplot as plt
>>
>> x = np.arange(100)
>>
>> plt.figure()
>> plt.plot(x, x**2)
>> z.show(plt, width='300px')
>> plt.close()
>>
>> But if I change x value to x= np.linspace(-2, 2, 1000), as it it used in
>> the example, I got
>>
>> <matplotlib.figure.Figure object at 0x7fa177d197b8>
>> [<matplotlib.lines.Line2D object at 0x7fa177ecf080>]
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "<stdin>", line 23, in show
>> File "<stdin>", line 69, in show_matplotlib
>> UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in
>> position 17262: ordinal not in range(128)
>>
>> I did some testing, and I found if any of the value passed to plot()
>> contains negative numbers, I will get this error...very odd.
>>
>>
>>
>> On Wed, Sep 14, 2016 at 8:50 AM Felix Cheung <fe...@hotmail.com>
>> wrote:
>>
>>> And
>>> matplotlib.use('Agg')
>>>
>>> Would only work before matplotlib is first used so you would need to
>>> restart the interpreter. From error stack below it looks like something
>>> might be setting the default backend in matplotlib to TkAgg though.
>>>
>>> Are you using the Python interpreter or PySpark interpreter? Also how
>>> you are calling matplotlib like Moon asks?
>>>
>>> _____________________________
>>> From: moon soo Lee <mo...@apache.org>
>>> Sent: Tuesday, September 13, 2016 2:34 PM
>>> Subject: Re: Matplotlib uses tkinter instead of Agg
>>> To: <us...@zeppelin.apache.org>
>>>
>>>
>>>
>>> Hi,
>>>
>>> Thanks for sharing the problem.
>>> Could you share which version of Zeppelin are you using and how did you
>>> try matplotlib inside of Zeppelin? Are you trying matplotlib with
>>> z.show() ?
>>>
>>> Thanks,
>>> moon
>>>
>>> On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com> wrote:
>>>
>>>> Hi,
>>>>
>>>> I want to build a Zeppelin docker image for my self. The docker image
>>>> is based on ubuntu:wily, and has openjdk-8-jre and python3 installed. I
>>>> also installed other packages that I need.
>>>>
>>>> After started Zeppelin in the docker, I am able to access the webapp
>>>> from my local browser. I tried to execute some simple Python script, and it
>>>> works fine. But when I try to run the matplotlib example, I got error
>>>> saying that tkinter cannot find the $DISPLAY.
>>>>
>>>> Traceback (most recent call last):
>>>> File "<stdin>", line 1, in <module>
>>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py",
>>>> line 535, in figure
>>>> **kwargs)
>>>> File
>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>> line 84, in new_figure_manager
>>>> return new_figure_manager_given_figure(num, figure)
>>>> File
>>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>>> line 92, in new_figure_manager_given_figure
>>>> window = Tk.Tk()
>>>> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in __init__
>>>> self.tk = _tkinter.create(screenName, baseName, className,
>>>> interactive, wantobjects, useTk, sync, use)
>>>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>>>>
>>>> Some people on the Internet suggested adding matplotlib.use('Agg') at
>>>> the beginning of the notebook, but it still does not work for me.
>>>>
>>>> --
>>>>
>>>>
>>>> Thanks,
>>>> David S.
>>>>
>>>
>>>
>>> --
>>
>>
>> Thanks,
>> David S.
>>
> --
>
>
> Thanks,
> David S.
>

Re: Matplotlib uses tkinter instead of Agg

Posted by Xi Shen <da...@gmail.com>.
OK, for this problem, it is discussed at
https://stackoverflow.com/questions/15538099/conversion-of-unicode-minus-sign-from-matplotlib-ticklabels

However, I just tried with Jupyter notebook, and its matplotlib can plot
with negative values on the axes correctly, and
matplotlib.rcParams['axes.unicode_minus'] = True.

Can you guys please check if this only happens to a Python3 environment? I
don't think I am the first one hit this problem.



On Wed, Sep 14, 2016 at 5:49 PM Xi Shen <da...@gmail.com> wrote:

> Hi,
>
> I worked it out...So I have start a new instance of Zeppelin...creating a
> new notebook wont take effect...So all the Python code are executed in one
> python vm? Shouldn't separating ones are better?
>
> After I get matplotlib work, I have a new problem.
>
> This code snippet works
> %python
>
> import numpy as np
> import matplotlib.pyplot as plt
>
> x = np.arange(100)
>
> plt.figure()
> plt.plot(x, x**2)
> z.show(plt, width='300px')
> plt.close()
>
> But if I change x value to x= np.linspace(-2, 2, 1000), as it it used in
> the example, I got
>
> <matplotlib.figure.Figure object at 0x7fa177d197b8>
> [<matplotlib.lines.Line2D object at 0x7fa177ecf080>]
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "<stdin>", line 23, in show
> File "<stdin>", line 69, in show_matplotlib
> UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in
> position 17262: ordinal not in range(128)
>
> I did some testing, and I found if any of the value passed to plot()
> contains negative numbers, I will get this error...very odd.
>
>
>
> On Wed, Sep 14, 2016 at 8:50 AM Felix Cheung <fe...@hotmail.com>
> wrote:
>
>> And
>> matplotlib.use('Agg')
>>
>> Would only work before matplotlib is first used so you would need to
>> restart the interpreter. From error stack below it looks like something
>> might be setting the default backend in matplotlib to TkAgg though.
>>
>> Are you using the Python interpreter or PySpark interpreter? Also how you
>> are calling matplotlib like Moon asks?
>>
>> _____________________________
>> From: moon soo Lee <mo...@apache.org>
>> Sent: Tuesday, September 13, 2016 2:34 PM
>> Subject: Re: Matplotlib uses tkinter instead of Agg
>> To: <us...@zeppelin.apache.org>
>>
>>
>>
>> Hi,
>>
>> Thanks for sharing the problem.
>> Could you share which version of Zeppelin are you using and how did you
>> try matplotlib inside of Zeppelin? Are you trying matplotlib with
>> z.show() ?
>>
>> Thanks,
>> moon
>>
>> On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I want to build a Zeppelin docker image for my self. The docker image is
>>> based on ubuntu:wily, and has openjdk-8-jre and python3 installed. I also
>>> installed other packages that I need.
>>>
>>> After started Zeppelin in the docker, I am able to access the webapp
>>> from my local browser. I tried to execute some simple Python script, and it
>>> works fine. But when I try to run the matplotlib example, I got error
>>> saying that tkinter cannot find the $DISPLAY.
>>>
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py", line
>>> 535, in figure
>>> **kwargs)
>>> File
>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>> line 84, in new_figure_manager
>>> return new_figure_manager_given_figure(num, figure)
>>> File
>>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>>> line 92, in new_figure_manager_given_figure
>>> window = Tk.Tk()
>>> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in __init__
>>> self.tk = _tkinter.create(screenName, baseName, className, interactive,
>>> wantobjects, useTk, sync, use)
>>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>>>
>>> Some people on the Internet suggested adding matplotlib.use('Agg') at
>>> the beginning of the notebook, but it still does not work for me.
>>>
>>> --
>>>
>>>
>>> Thanks,
>>> David S.
>>>
>>
>>
>> --
>
>
> Thanks,
> David S.
>
-- 


Thanks,
David S.

Re: Matplotlib uses tkinter instead of Agg

Posted by Xi Shen <da...@gmail.com>.
Hi,

I worked it out...So I have start a new instance of Zeppelin...creating a
new notebook wont take effect...So all the Python code are executed in one
python vm? Shouldn't separating ones are better?

After I get matplotlib work, I have a new problem.

This code snippet works
%python

import numpy as np
import matplotlib.pyplot as plt

x = np.arange(100)

plt.figure()
plt.plot(x, x**2)
z.show(plt, width='300px')
plt.close()

But if I change x value to x= np.linspace(-2, 2, 1000), as it it used in
the example, I got

<matplotlib.figure.Figure object at 0x7fa177d197b8>
[<matplotlib.lines.Line2D object at 0x7fa177ecf080>]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 23, in show
File "<stdin>", line 69, in show_matplotlib
UnicodeEncodeError: 'ascii' codec can't encode character '\u2212' in
position 17262: ordinal not in range(128)

I did some testing, and I found if any of the value passed to plot()
contains negative numbers, I will get this error...very odd.



On Wed, Sep 14, 2016 at 8:50 AM Felix Cheung <fe...@hotmail.com>
wrote:

> And
> matplotlib.use('Agg')
>
> Would only work before matplotlib is first used so you would need to
> restart the interpreter. From error stack below it looks like something
> might be setting the default backend in matplotlib to TkAgg though.
>
> Are you using the Python interpreter or PySpark interpreter? Also how you
> are calling matplotlib like Moon asks?
>
> _____________________________
> From: moon soo Lee <mo...@apache.org>
> Sent: Tuesday, September 13, 2016 2:34 PM
> Subject: Re: Matplotlib uses tkinter instead of Agg
> To: <us...@zeppelin.apache.org>
>
>
>
> Hi,
>
> Thanks for sharing the problem.
> Could you share which version of Zeppelin are you using and how did you
> try matplotlib inside of Zeppelin? Are you trying matplotlib with
> z.show() ?
>
> Thanks,
> moon
>
> On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com> wrote:
>
>> Hi,
>>
>> I want to build a Zeppelin docker image for my self. The docker image is
>> based on ubuntu:wily, and has openjdk-8-jre and python3 installed. I also
>> installed other packages that I need.
>>
>> After started Zeppelin in the docker, I am able to access the webapp from
>> my local browser. I tried to execute some simple Python script, and it
>> works fine. But when I try to run the matplotlib example, I got error
>> saying that tkinter cannot find the $DISPLAY.
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py", line
>> 535, in figure
>> **kwargs)
>> File
>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>> line 84, in new_figure_manager
>> return new_figure_manager_given_figure(num, figure)
>> File
>> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
>> line 92, in new_figure_manager_given_figure
>> window = Tk.Tk()
>> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in __init__
>> self.tk = _tkinter.create(screenName, baseName, className, interactive,
>> wantobjects, useTk, sync, use)
>> _tkinter.TclError: no display name and no $DISPLAY environment variable
>>
>> Some people on the Internet suggested adding matplotlib.use('Agg') at the
>> beginning of the notebook, but it still does not work for me.
>>
>> --
>>
>>
>> Thanks,
>> David S.
>>
>
>
> --


Thanks,
David S.

Re: Matplotlib uses tkinter instead of Agg

Posted by Felix Cheung <fe...@hotmail.com>.
And
matplotlib.use('Agg')

Would only work before matplotlib is first used so you would need to restart the interpreter. From error stack below it looks like something might be setting the default backend in matplotlib to TkAgg though.

Are you using the Python interpreter or PySpark interpreter? Also how you are calling matplotlib like Moon asks?

_____________________________
From: moon soo Lee <mo...@apache.org>>
Sent: Tuesday, September 13, 2016 2:34 PM
Subject: Re: Matplotlib uses tkinter instead of Agg
To: <us...@zeppelin.apache.org>>


Hi,

Thanks for sharing the problem.
Could you share which version of Zeppelin are you using and how did you try matplotlib inside of Zeppelin? Are you trying matplotlib with z.show() ?

Thanks,
moon

On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com>> wrote:
Hi,

I want to build a Zeppelin docker image for my self. The docker image is based on ubuntu:wily, and has openjdk-8-jre and python3 installed. I also installed other packages that I need.

After started Zeppelin in the docker, I am able to access the webapp from my local browser. I tried to execute some simple Python script, and it works fine. But when I try to run the matplotlib example, I got error saying that tkinter cannot find the $DISPLAY.

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py", line 535, in figure
**kwargs)
File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py", line 84, in new_figure_manager
return new_figure_manager_given_figure(num, figure)
File "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py", line 92, in new_figure_manager_given_figure
window = Tk.Tk()
File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in __init__
self.tk<http://self.tk> = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

Some people on the Internet suggested adding matplotlib.use('Agg') at the beginning of the notebook, but it still does not work for me.

--

Thanks,
David S.



Re: Matplotlib uses tkinter instead of Agg

Posted by moon soo Lee <mo...@apache.org>.
Hi,

Thanks for sharing the problem.
Could you share which version of Zeppelin are you using and how did you try
matplotlib inside of Zeppelin? Are you trying matplotlib with z.show() ?

Thanks,
moon

On Tue, Sep 13, 2016 at 1:56 AM Xi Shen <da...@gmail.com> wrote:

> Hi,
>
> I want to build a Zeppelin docker image for my self. The docker image is
> based on ubuntu:wily, and has openjdk-8-jre and python3 installed. I also
> installed other packages that I need.
>
> After started Zeppelin in the docker, I am able to access the webapp from
> my local browser. I tried to execute some simple Python script, and it
> works fine. But when I try to run the matplotlib example, I got error
> saying that tkinter cannot find the $DISPLAY.
>
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "/usr/local/lib/python3.4/dist-packages/matplotlib/pyplot.py", line
> 535, in figure
> **kwargs)
> File
> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
> line 84, in new_figure_manager
> return new_figure_manager_given_figure(num, figure)
> File
> "/usr/local/lib/python3.4/dist-packages/matplotlib/backends/backend_tkagg.py",
> line 92, in new_figure_manager_given_figure
> window = Tk.Tk()
> File "/usr/lib/python3.4/tkinter/__init__.py", line 1859, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive,
> wantobjects, useTk, sync, use)
> _tkinter.TclError: no display name and no $DISPLAY environment variable
>
> Some people on the Internet suggested adding matplotlib.use('Agg') at the
> beginning of the notebook, but it still does not work for me.
>
> --
>
>
> Thanks,
> David S.
>