PyQt5 在导入 skimage 时出现问题

Posted

技术标签:

【中文标题】PyQt5 在导入 skimage 时出现问题【英文标题】:PyQt5 has issue while importing in skimage 【发布时间】:2017-12-04 19:36:39 【问题描述】:

我正在使用 Skimage 处理 RGB 颜色处理的图像,并具有以下软件包配置:

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()

期望输出为图像

预期输出

我得到以下错误:

(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

【问题讨论】:

我看到 skimage 需要 PyQt4,而不是你安装了 PyQt5:pyqt 5.6.0,一个可能的解决方案是安装 PyQt4。阅读:***.com/questions/21637922/… 我添加了一个问题来解决这个问题:github.com/scikit-image/scikit-image/issues/2912 【参考方案1】:

我使用 pip 19.1.1 和 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'

在我出错之前

解决者:

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

在此之前,我已经安装了

D:\tesF> pip install PyQt5

【讨论】:

以上是关于PyQt5 在导入 skimage 时出现问题的主要内容,如果未能解决你的问题,请参考以下文章

导入 PyQt5 时出现 RuntimeError

PyQt5:使用 QObject 和 QThread 时出现 AttributeError

尝试让 PyQt5 与 Pycharm 一起使用时出现错误和问题

PyQt5 Pyinstaller时出现错误Cannot find PyQt5 plugin directories

ImportError:导入 _remap 时 DLL 加载失败

导入错误 No module named skimage