junyanz / interactive-deep-colorization

Deep learning software for colorizing black and white images with a few clicks.
https://richzhang.github.io/ideepcolor/
MIT License
2.69k stars 447 forks source link

force using qt4 #5

Closed blshkv closed 7 years ago

blshkv commented 7 years ago

I have both PyQt4 and PyQt5 libraries installed. matplotlib choses qt5 backend by default and the software fails with the following:

bash$ ideepcolor 
Traceback (most recent call last):
  File "/usr/share/ideepcolor/ideepcolor.py", line 12, in <module>
    from ui import gui_design
  File "/usr/share/ideepcolor/ui/gui_design.py", line 3, in <module>
    from . import gui_draw
  File "/usr/share/ideepcolor/ui/gui_draw.py", line 15, in <module>
    import matplotlib.pyplot as plt
  File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 109, 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 32, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 18, in <module>
    from .backend_qt5 import QtCore
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_qt5.py", line 27, in <module>
    import matplotlib.backends.qt_editor.figureoptions as figureoptions
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 17, in <module>
    import matplotlib.backends.qt_editor.formlayout as formlayout
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/qt_editor/formlayout.py", line 58, in <module>
    from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
  File "/usr/lib64/python2.7/site-packages/matplotlib/backends/qt_compat.py", line 111, in <module>
    from PyQt5 import QtCore, QtGui, QtWidgets
RuntimeError: the PyQt5.QtCore and PyQt4.QtCore modules both wrap the QObject class

The following patch fixes the problem (sorry, I'm too lazy for the proper pull request):

--- ui/gui_draw.py.orig    2017-05-19 12:52:25.000000000 +0800
+++ ui/gui_draw.py 2017-05-19 12:53:07.648466907 +0800
@@ -12,6 +12,9 @@
 import glob
 import sys
 from pdb import set_trace as st
+
+import matplotlib as mpl
+mpl.use("Qt4Agg")
 import matplotlib.pyplot as plt

 import skimage
blshkv commented 7 years ago

hm? Any reason why you closed the issue without fixing it? I tried the latest git 8247da3cc83e54201b20d5a67b997120bb368436 it still causes the same issue.

I can't re-open the bug so it is up to you.

junyanz commented 7 years ago

@blshkv Thank you for pointing out the issue. I added the mpl.use('Qt4Agg'). Let me know if it works for you.