Re: Matplotlib uses tkinter instead of Agg
> 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 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 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 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 >>>>>> 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 >>>>>>> >>>>>>> >>>>>>> [] >>>>>>> >>>>>>> Traceback (most recent call last): >>>>>>> File "", line 1, in >>>>>>> File "", line 23, in show >>>>>>> File "", 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 < >>>>>>> felixcheun...@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 >>>>>>>> Sent: Tuesday, September 13, 2016 2:34 PM >>>>>>>> Subject: Re: Matplotlib uses tkinter instead of Agg >>>>>>>> To: >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> 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 >>>>>>>> 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 "", line 1, in >>>>>>>>> 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
low.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 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 >>>>>> >>>>>> >>>>>> [] >>>>>> >>>>>> Traceback (most recent call last): >>>>>> File "", line 1, in >>>>>> File "", line 23, in show >>>>>> File "", 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 < >>>>>> felixcheun...@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 >>>>>>> Sent: Tuesday, September 13, 2016 2:34 PM >>>>>>> Subject: Re: Matplotlib uses tkinter instead of Agg >>>>>>> To: >>>>>>> >>>>>>> >>>>>>> >>>>>>> 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 >>>>>>> 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 "", line 1, in >>>>>>>> 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
t;>> 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 >>>>> >>>>> >>>>> [] >>>>> >>>>> Traceback (most recent call last): >>>>> File "", line 1, in >>>>> File "", line 23, in show >>>>> File "", 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 < >>>>> felixcheun...@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 >>>>>> Sent: Tuesday, September 13, 2016 2:34 PM >>>>>> Subject: Re: Matplotlib uses tkinter instead of Agg >>>>>> To: >>>>>> >>>>>> >>>>>> >>>>>> 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 >>>>>> 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 "", line 1, in >>>>>>> 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
w 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 >>>>> >>>>> >>>>> [] >>>>> >>>>> Traceback (most recent call last): >>>>> File "", line 1, in >>>>> File "", line 23, in show >>>>> File "", 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 < >>>>> felixcheun...@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 >>>>>> Sent: Tuesday, September 13, 2016 2:34 PM >>>>>> Subject: Re: Matplotlib uses tkinter instead of Agg >>>>>> To: >>>>>> >>>>>> >>>>>> >>>>>> 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 >>>>>> 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 "", line 1, in >>>>>>> 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
>> 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 >>>> >>>> >>>> [] >>>> >>>> Traceback (most recent call last): >>>> File "", line 1, in >>>> File "", line 23, in show >>>> File "", 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 >>>> 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 >>>>> Sent: Tuesday, September 13, 2016 2:34 PM >>>>> Subject: Re: Matplotlib uses tkinter instead of Agg >>>>> To: >>>>> >>>>> >>>>> >>>>> 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 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 "", line 1, in >>>>>> 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
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 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 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 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 >>> >>> >>> [] >>> >>> Traceback (most recent call last): >>> File "", line 1, in >>> File "", line 23, in show >>> File "", 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 >>> 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 >>>> Sent: Tuesday, September 13, 2016 2:34 PM >>>> Subject: Re: Matplotlib uses tkinter instead of Agg >>>> To: >>>> >>>> >>>> >>>> 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 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 "", line 1, in >>>>> 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
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 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 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 >> >> >> [] >> >> Traceback (most recent call last): >> File "", line 1, in >> File "", line 23, in show >> File "", 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 >> 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 >>> Sent: Tuesday, September 13, 2016 2:34 PM >>> Subject: Re: Matplotlib uses tkinter instead of Agg >>> To: >>> >>> >>> >>> 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 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 "", line 1, in >>>> 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
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 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 > > > [] > > Traceback (most recent call last): > File "", line 1, in > File "", line 23, in show > File "", 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 > 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 >> Sent: Tuesday, September 13, 2016 2:34 PM >> Subject: Re: Matplotlib uses tkinter instead of Agg >> To: >> >> >> >> 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 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 "", line 1, in >>> 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
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 [] Traceback (most recent call last): File "", line 1, in File "", line 23, in show File "", 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 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 > Sent: Tuesday, September 13, 2016 2:34 PM > Subject: Re: Matplotlib uses tkinter instead of Agg > To: > > > > 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 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 "", line 1, in >> 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
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 mailto:m...@apache.org>> Sent: Tuesday, September 13, 2016 2:34 PM Subject: Re: Matplotlib uses tkinter instead of Agg To: mailto:users@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 mailto:davidshe...@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 "", line 1, in 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
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 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 "", line 1, in > 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. >