PyPlot.jl
PyPlot.jl copied to clipboard
Segfault with qt >=4.8.6 on ubuntu
I updated my (systemwide) miniconda installation but now PyPlot is in trouble:
julia> using PyPlot
julia> plot(1:10, randn(10))
signal(11): Segmentation fault
unknown function (ip: 0x32736)
unknown function (ip: (nil))
[1] 4493 segmentation fault: julia
The issue remains with a fresh installation of PyPlot and ENV["PYTHON"] = ""
to ensure that a fresh download of Conda.jl is used instead. But everything is fine if I plot from Python directly. I'm using julia 0.4.6 on Linux x86_64 (ubuntu 16.04).
Anything I can do to diagnose this further?
Can you try Pkg.checkout("PyCall"); Pkg.build("PyCall")
to see if the problem persists with PyCall master?
Or actually maybe you just need to re-run Pkg.build("PyCall")
.
Problem still persists - here's a backtrace.
OK, downgrading python/qt/sip works:
$ conda install python=3.4 pyqt=4.10
[...]
The following packages will be DOWNGRADED due to dependency conflicts:
pyqt: 4.11.4-py35_4 --> 4.10.4-py34_0
python: 3.5.2-0 --> 3.4.5-0
qt: 4.8.7-4 --> 4.8.5-0
sip: 4.18-py35_0 --> 4.15.5-py34_0
The problem therefore appeared somewhere in these updates.
Are you using the same backend (qt) in Julia and when you call Matplotlib directly from Conda's Python?
Yes I am.
julia> using PyPlot
julia> pygui(:qt)
:qt
julia> figure()
signal (11): Segmentation fault
unknown function (ip: 0x32736)
unknown function (ip: (nil))
[1] 27445 segmentation fault julia
~❯ ipython
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:53:06)
Type "copyright", "credits" or "license" for more information.
IPython 5.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: %pylab qt
Populating the interactive namespace from numpy and matplotlib
In [2]: figure()
Out[2]: <matplotlib.figure.Figure at 0x7f06a03d4940>
That's again using a system miniconda install, but same thing if I let Conda do it.
What happens if you use a different backend, e.g. tk?
Works fine:
julia> using PyCall
julia> pygui(:tk)
:tk
julia> using PyPlot
julia> figure()
PyPlot.Figure(PyObject <matplotlib.figure.Figure object at 0x7f9a9baf2780>)
That's helpful, so it is something about the way we are calling Qt (presumably the event loop in PyCall/src/gui.jl) that doesn't work any more...
What happens if you just start the Qt event loop? using PyCall; pygui_start(:qt)
.
That also works just fine.
Does Conda with Python2 work?
No. When I tested it with Conda.jl, which uses Python 2, it didn't work with the newer Qt either.
If anyone reading this needs a temporary workaround, you should be able to do Conda.add("qt=4.8.5")
to downgrade your version of qt.
Just tried it on MacOS and PyPlot is working fine with Conda and pyqt-4.11.4, so it may be something specific to Linux.
I've been able to run it successfully on a different Linux box, so it's only specific to my machine at the moment :/
Ah, maybe its a conflict in your library paths somehow? Maybe you have multiple libqt
libraries installed and the system is getting confused about which one to load or something?
I don't believe I have any other libqt libraries installed. The only place seems to be in the conda directory. I've confirmed that the crash is related to the version of qt
in the conda environment: it happens for version 4.8.6 and above.
This happens to me as well, but it dissapears by running julia with root permission. Hope this helps:
signal (11): Segmentation fault
unknown function (ip: 0x32736)
[1] 14234 segmentation fault (core dumped) julia
Huh - yes I can confirm that running julia as root also gets around this.
Would be nice to have a fix for this though, Plots.jl
has this as a dependency
Plots.jl has this as a dependency
No it doesn't
Sorry, I meant uses it as default backend.
Just for the record, I have this exact same issue. This crashes (normal Conda.jl install):
using PyPlot
plot(rand(10))
This works:
using PyCall
pygui(:tk)
using PyPlot
plot(rand(10))
and this works as well:
import Conda
Conda.add("qt=4.8.5")
using PyPlot
plot(rand(10))
I'm on Ubuntu:
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.5.0-rc0+111 (2016-08-01 19:26 UTC)
_/ |\__'_|_|_|\__'_| | tb_pkgsha/7f3e776 (fork: 1 commits, 1 day)
|__/ | x86_64-linux-gnu
- PyCall 1.6.3
- PyPlot 2.2.0+ 985eb4bb master
- Conda 0.2.2
Here is the list of changes in 4.8.6 compared to 4.8.5. Nothing jumps out at me at first glance, though.
I had a same problem. My solution was:
installed matplotlib from the ubuntu repo (followed by this site)
http://scipy.org/install.html
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose
After I reinstalled PyPlot, and it works fine.
Ubuntu repositories usually lag the latest version, so it's quite possible that the version of Qt you get from the repositories is 4.8.5 or earlier. It may still break in future.
I also don't see anything in the change log that jumps out. The advice I've seen for other problems with Qt is along the lines of "move to Qt5 as this is being actively developed" - is it worth trying it instead of Qt4?
We should certainly support the qt5 backend, but we can't stop people from specifying the qt4 backend.
I'm worried that this issue is going to result in a bad first impression: 0.5 is released, a wave of people try it out, install PyPlot or Plots, get a segfault and swamp you and @tbreloff with complaints! But I don't know how one goes about understanding the cause of a segfault. I guess with Gallium up and running now it might be worth stepping through and seeing where the error occurs.
Well, the default backend is tk
, so doesn't this only affect people if they (a) have the newer qt and (b) specify the qt backend in their .matplotlibrc
?
@krisztiankosi's experience suggests that there may be some problem with matplotlib after all — if upgrading matplotlib fixes the problem, hopefully this will go away once Ubuntu has a newer matplotlib?
@krisztiankosi, are you still using the qt backend? (Look at PyPlot.backend
)
the default backend is tk, so doesn't this only affect people if they (a) have the newer qt and (b) specify the qt backend in their .matplotlibrc?
I'm not sure if this is true. I think mine defaults to pyqt4? I never set anything in the .matplotlibrc, so it's using a default value from somewhere. I'm not at my ubuntu desktop right now so I can't check.