Search code examples
pythonanacondapyqt5scikit-image

PyQt5 has issue while importing in skimage


I am working on image for RGB color manipulation using Skimage and having below configuration of packages:

Python 3.6.1

scikit-image 0.13.0

pyqt 5.6.0

from skimage import io

import sip
sip.setapi('QString', 2)
from PyQt5 import QtGui

io.use_plugin('pil','imread')

img=io.imread('RpMkYUX.jpg')
io.use_plugin('qt' ,'imshow')
io.imshow(img)
io.show()

expecting output as in image

expected output

and i am getting below error as:

(C:\Users\rahul\Anaconda3) C:\Users\rahul\AnacondaProjects\15_PIL>python 2_.py
Traceback (most recent call last):
  File "C:\Users\rahul\Anaconda3\lib\site-packages\skimage\io\_plugins\qt_plugin.py", line 11, in <module>
    from PyQt4.QtGui import (QApplication, QImage,
ModuleNotFoundError: No module named 'PyQt4'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "2_.py", line 16, in <module>
    io.use_plugin('qt' ,'imshow')
  File "C:\Users\rahul\Anaconda3\lib\site-packages\skimage\io\manage_plugins.py", line 255, in use_plugin
    _load(name)
  File "C:\Users\rahul\Anaconda3\lib\site-packages\skimage\io\manage_plugins.py", line 299, in _load
    fromlist=[modname])
  File "C:\Users\rahul\Anaconda3\lib\site-packages\skimage\io\_plugins\qt_plugin.py", line 28, in <module>
    """)
ImportError:     PyQt4 libraries not installed. Please refer to

    http://www.riverbankcomputing.co.uk/software/pyqt/intro

    for more information.  PyQt4 is GPL licensed.  For an
    LGPL equivalent, see

    http://www.pyside.org

Solution

  • I use pip 19.1.1 and Python 3.7.4

    D:\tesF> python scikit-image-tes.py
    Traceback (most recent call last):
      File "scikit-image-tes.py", line 10, in <module>
        io.use_plugin('qt' ,'imshow')
      File "C:\Users\pcname\AppData\Roaming\Python\Python37\site-packages\skimage\io\manage_plugins.py", line 254, in use_plugin
        _load(name)
      File "C:\Users\pcname\AppData\Roaming\Python\Python37\site-packages\skimage\io\manage_plugins.py", line 298, in _load
        fromlist=[modname])
      File "C:\Users\pcname\AppData\Roaming\Python\Python37\site-packages\skimage\io\_plugins\qt_plugin.py", line 5, in <module>
        from qtpy.QtWidgets import (QApplication, QLabel, QMainWindow, QWidget,
    ModuleNotFoundError: No module named 'qtpy'
    

    Before I've got error

    Solved by:

    D:\tesF> pip install sip
    D:\tesF> pip install qtpy
    

    before that, I've installed

    D:\tesF> pip install PyQt5