In one of my machines, it has become impossible for me to use PyPlot and ImageView at the same time, Julia crashes with a message like:
XmbTextListToTextProperty result code -2
XmbTextListToTextProperty result code -2
XmbTextListToTextProperty result code -2
julia> imshow(ii)
signal (11): Segmentation fault
in expression starting at REPL[9]:1
_PyErr_Restore at /home/nicolau/.julia/conda/3/lib/libpython3.8.so.1.0 (unknown line)
PyDict_GetItem at /home/nicolau/.julia/conda/3/lib/libpython3.8.so.1.0 (unknown line)
Is this an issue I should bring up to the ImageView, PyPlot, PyCall or Julia projects?.. And are there any workarounds I can try?
It has been long time, but this or similar error was solved by this:
opened 06:31PM - 20 Oct 15 UTC
closed 06:49PM - 20 Oct 15 UTC
I'm not able to use both PyPlot and Gtk at the same time. I get different probl… ems depending on which I import first:
```
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.4.0 (2015-10-08 06:20 UTC)
_/ |\__'_|_|_|\__'_| |
|__/ | x86_64-redhat-linux
julia> using Gtk
julia> using PyPlot
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_boxed_type_register_static: assertion 'g_type_from_name (name) == 0' failed
from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_set_qdata: assertion 'node != NULL' failed
from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type 'GtkWidget'
from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_add_interface_static: assertion 'G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: cannot register existing type 'GtkBuildable'
from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_interface_add_prerequisite: assertion 'G_TYPE_IS_INTERFACE (interface_type)' failed
from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_once_init_leave: assertion 'result != 0' failed
from gtk import _gtk
/usr/lib64/python2.7/site-packages/gtk-2.0/gtk/__init__.py:40: Warning: g_type_register_static: assertion 'parent_type > 0' failed
from gtk import _gtk
^C/usr/lib64/python2.7/site-packages/matplotlib/__init__.py:1005: UserWarning: This call to matplotlib.use() has no effect
because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot,
or matplotlib.backends is imported for the first time.
warnings.warn(_use_error_msg)
ERROR: InitError: PyError (:PyImport_ImportModule) <type 'exceptions.AttributeError'>
AttributeError("'module' object has no attribute 'gdk'",)
File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 97, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 13, in <module>
import gtk; gdk = gtk.gdk
[inlined code] from /home/tom/.julia/v0.4/PyCall/src/exception.jl:81
in pyimport at /home/tom/.julia/v0.4/PyCall/src/PyCall.jl:79
in __init__ at /home/tom/.julia/v0.4/PyPlot/src/PyPlot.jl:250
in _require_from_serialized at loading.jl:84
in _require_from_serialized at ./loading.jl:109
in require at ./loading.jl:219
during initialization of module PyPlot
julia>
[tom@tomoffice Plots]$ julia
_
_ _ _(_)_ | A fresh approach to technical computing
(_) | (_) (_) | Documentation: http://docs.julialang.org
_ _ _| |_ __ _ | Type "?help" for help.
| | | | | | |/ _` | |
| | |_| | | | (_| | | Version 0.4.0 (2015-10-08 06:20 UTC)
_/ |\__'_|_|_|\__'_| |
|__/ | x86_64-redhat-linux
julia> using PyPlot
julia> using Gtk
sys:1: Warning: cannot register existing type 'GdkDisplayManager'
sys:1: Warning: g_once_init_leave: assertion 'result != 0' failed
sys:1: Warning: g_type_register_static: assertion 'parent_type > 0' failed
sys:1: Warning: g_object_new: assertion 'G_TYPE_IS_OBJECT (object_type)' failed
^CERROR: InitError: InterruptException:
in anonymous at /home/tom/.julia/v0.4/Gtk/src/events.jl:11
in call at /home/tom/.julia/v0.4/Gtk/src/GLib/gerror.jl:13
in __init__ at /home/tom/.julia/v0.4/Gtk/src/events.jl:10
in _require_from_serialized at loading.jl:84
in _require_from_serialized at ./loading.jl:109
in require at ./loading.jl:219
during initialization of module Gtk
julia>
```
cc: @stevengj
Basically, add backend: WebAgg
in your matplotlibrc.
matplotlibrc is located somewhere like this:
somefolder/lib/python3.9/site-packages/matplotlib/mpl-data/matplotlibrc
At some point, I didn’t have to add backend: WebAgg and pyplot and imageview both worked fine. However, I noticed that pyplot elicited some fatal errors after some work with multithreading. After adding the backend magic, it does not give any trouble.