pyplot doesn't display anything, how do I choose the right backend

738 views
Skip to first unread message

thr

unread,
Dec 3, 2014, 1:39:36 PM12/3/14
to julia...@googlegroups.com


Hi,

I try to use pyplot.jl, nothing works, I need help :)

In python, I can use matplotlib with both the gtk3 and wx backends. But Julia tells me

WARNING: No working GUI backend found for matplotlib.

when I try using PyPlot.

Calls to pygui(:gtk) and pygui(:wx) tell me that I don't have the corresponding GUI toolkits installed, but I have.

If I understand correctly, even with no working pygui, I should be able to see figures, through display(gcf()), but that also doesn't work. The actual code I tried is:

using PyCall
#pygui(:gtk)
using PyPlot

x
= linspace(0,2*pi,1000); y = sin(3*x + 4*cos(2*x));
plot
(x, y, color="red", linewidth=2.0, linestyle="--")

display
(gcf())




did I miss something?

thr

unread,
Dec 3, 2014, 2:08:50 PM12/3/14
to julia...@googlegroups.com
Sorry, I forgot to mention the versions: Julia 0.3, python 3.3.5, matplotlib 1.3 on gentoo.

Isaiah Norton

unread,
Dec 3, 2014, 2:25:26 PM12/3/14
to julia...@googlegroups.com
Might be a paths issue - check the contents of 'sys.path' when running python directly vs. PyCall.

Steven G. Johnson

unread,
Dec 3, 2014, 3:38:42 PM12/3/14
to julia...@googlegroups.com
Yeah, probably you are running a different version of Python (or a different Python path) in Julia than you are when you run Python separately.   (You can use the PYTHON environment variable to specify the path of the python executable that you want Julia to use.)

Steven G. Johnson

unread,
Dec 3, 2014, 3:40:52 PM12/3/14
to julia...@googlegroups.com
On Wednesday, December 3, 2014 2:08:50 PM UTC-5, thr wrote:
Sorry, I forgot to mention the versions: Julia 0.3, python 3.3.5, matplotlib 1.3 on gentoo.

I'm guessing that you also have python2 installed, and Julia is picking up that instead because python==python2 in your PATH.  Try
    PYTHON=python3 julia
assuming that your Python 3.3 executable is called python3 and is in the PATH.

thr

unread,
Dec 3, 2014, 7:28:05 PM12/3/14
to julia...@googlegroups.com

Almost :) This gave me the right direction.
In fact, I have two pythons, but I have to explicitly set PYTHON=python2.7 if I want to see interactive graphs.

Here is what I found out about the combinations of backends and python versions:

Backends gtk3agg, gtk3cairo, wx, wxagg just seemed to work in both pythons. It turned out that they don't work interactively (i.e. with matplotlib.interactive(true)) due to some bug with matplotlib on the python side.
Backend TkAgg works with both pythons, but TkAgg doesn't seem to work with PyPlot. This is what I set in my matplotlibrc, which seems to be ignored by PyPlot.
Backend gtkAgg works with Python2.7 and PyPlot, but NOT with python3.

I don't know about the qt backend. I suspect this is the only one working with python3 and Julia.

Steven G. Johnson

unread,
Dec 3, 2014, 10:06:47 PM12/3/14
to julia...@googlegroups.com


On Wednesday, December 3, 2014 7:28:05 PM UTC-5, thr wrote:
Backend TkAgg works with both pythons, but TkAgg doesn't seem to work with PyPlot. This is what I set in my matplotlibrc, which seems to be ignored by PyPlot.
Backend gtkAgg works with Python2.7 and PyPlot, but NOT with python3.

That's odd; TkAgg works on my machine, and PyPlot nowadays should honor your matplotlibrc if it can.   Can you try to do Pkg.update() to see if your packages are out of date?  If that fails, please file a PyPlot issue.

(The fact that gtk and wx don't work interactively even in Python probably means something is broken in your Python setup, which is a little worrying.)

James Dang

unread,
Dec 4, 2014, 3:53:23 AM12/4/14
to julia...@googlegroups.com
If you use it with IPython Notebook or with Lighttable, it should pretty much work out of the box I think.

thr

unread,
Dec 4, 2014, 2:05:58 PM12/4/14
to julia...@googlegroups.com
Ok, a Pkg.update() made :tk backend work, but still only with PYTHON=python2.7

And I'm sure that the tkAgg backend works in python3. I can import tkinter in all my pythons, but in Julia pyimport("tkinter") tells me:

ERROR: PyError (PyImport_ImportModule) <class 'ValueError'>
ValueError('character U+7273752f is not in range [U+0000; U+10ffff]',)
 
File "/usr/lib64/python3.3/tkinter/__init__.py", line 40, in <module>
   
import _tkinter # If this fails your Python may not be configured for Tk

 
in pyerr_check at /root/.julia/v0.4/PyCall/src/exception.jl:58
 
in pyimport at /root/.julia/v0.4/PyCall/src/PyCall.jl:85

Steven G. Johnson

unread,
Dec 4, 2014, 2:43:40 PM12/4/14
to julia...@googlegroups.com


On Thursday, December 4, 2014 2:05:58 PM UTC-5, thr wrote:
Ok, a Pkg.update() made :tk backend work, but still only with PYTHON=python2.7

And I'm sure that the tkAgg backend works in python3. I can import tkinter in all my pythons, but in Julia pyimport("tkinter") tells me:

pyimport("tkinter") works for me with Python 3.2.3 on Debian.  There may be something wrong with your config?
Message has been deleted

thr

unread,
Dec 4, 2014, 10:37:16 PM12/4/14
to julia...@googlegroups.com
I think I found the problem. I created an issue for it on github.

https://github.com/stevengj/PyCall.jl/issues/103
Reply all
Reply to author
Forward
0 new messages