Issue
I am working in electron microscopy and it is important for me (and other microscopist) to inspect data and pick up areas of the dataset interactively. To explore the dataset I usually use the PyQt5 backend of matplotlib.
For exemple : I want to be able to pick up and display an area of an image. Then If I find this area suitable for processing I would like to be able to use it as an input for a python script.
I installed everything so that PyQt5 should be working but when I try to use the Ipython magic command line : %matplotlib qt
an ImportError shows up (see code output section).
Searching on StackExchange I found this question : StackExchange issue. If I understood well it is normal to get such errors in the renkulab environment.
Can something be done to solve this issue regardless?
More generally about interactivity: Would it be possible in renku to have âhybridâ workflows were the user could have manual input during the processing of the data ?
Docker files
requirements.txt
cython==0.29.15
hyperspy==1.5.2
hyperspy_gui_ipywidgets==1.2
hyperspy_gui_traitsui==1.2
lmfit==1.0.0
PyQt5==5.14.1
DockerFile
FROM renku/singleuser:0.4.3-renku0.8.2
#Uncomment and adapt if code is to be included in the image
#COPY src /code/src
#Uncomment and adapt if your R or python packages require extra linux (ubuntu) software
#e.g. the following installs apt-utils and vim; each pkg on its own line, all lines
#except for the last end with backslash '\' to continue the RUN line
USER root
RUN apt-get update && \
apt-get install -y --no-install-recommends \
libgl1-mesa-glx
USER ${NB_USER}
#install the python dependencies
COPY requirements.txt environment.yml /tmp/
RUN conda env update -q -f /tmp/environment.yml && \
/opt/conda/bin/pip install -r /tmp/requirements.txt && \
conda clean -y --all && \
conda env export -n "root"
code ouput
import matplotlib
print(matplotlib.get_backend())
--> Qt5Agg
%matplotlib qt
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-7-325c2f98aa22> in <module>
----> 1 get_ipython().run_line_magic('matplotlib', 'qt')
/opt/conda/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2312 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2313 with self.builtin_trap:
-> 2314 result = fn(*args, **kwargs)
2315 return result
2316
</opt/conda/lib/python3.7/site-packages/decorator.py:decorator-gen-108> in matplotlib(self, line)
/opt/conda/lib/python3.7/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
/opt/conda/lib/python3.7/site-packages/IPython/core/magics/pylab.py in matplotlib(self, line)
97 print("Available matplotlib backends: %s" % backends_list)
98 else:
---> 99 gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
100 self._show_matplotlib_backend(args.gui, backend)
101
/opt/conda/lib/python3.7/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
3412 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
3413
-> 3414 pt.activate_matplotlib(backend)
3415 pt.configure_inline_support(self, backend)
3416
/opt/conda/lib/python3.7/site-packages/IPython/core/pylabtools.py in activate_matplotlib(backend)
312
313 import matplotlib.pyplot
--> 314 matplotlib.pyplot.switch_backend(backend)
315
316 # This must be imported last in the matplotlib series, after
/opt/conda/lib/python3.7/site-packages/matplotlib/pyplot.py in switch_backend(newbackend)
235 "Cannot load backend {!r} which requires the {!r} interactive "
236 "framework, as {!r} is currently running".format(
--> 237 newbackend, required_framework, current_framework))
238
239 rcParams['backend'] = rcParamsDefault['backend'] = newbackend
ImportError: Cannot load backend 'Qt5Agg' which requires the 'qt5' interactive framework, as 'headless' is currently running