Qt与OSX中的skimage有关

时间:2017-09-30 22:50:43

标签: python macos qt

我很难找到适当的步骤来获得在OSX上运行的skimage(以及它的QT组件)。我用这个例子来描绘:

import matplotlib
matplotlib.use('TkAgg')
from skimage import data
from skimage.viewer import ImageViewer

image = data.coins()
viewer = ImageViewer(image)
viewer.show()

出现了这个错误:

/Users/marcleonard/.virtualenvs/marcleonard-zP9HSj98/lib/python3.4/site-packages/skimage/viewer/__init__.py:6: UserWarning: Viewer requires Qt
  warn('Viewer requires Qt')
Traceback (most recent call last):
  File "/Users/marcleonard/Desktop/image-api/image-api.py", line 7, in <module>
    viewer = ImageViewer(image)
  File "/Users/marcleonard/.virtualenvs/marcleonard-zP9HSj98/lib/python3.4/site-packages/skimage/viewer/viewers/core.py", line 93, in __init__
    init_qtapp()
  File "/Users/marcleonard/.virtualenvs/marcleonard-zP9HSj98/lib/python3.4/site-packages/skimage/viewer/utils/core.py", line 28, in init_qtapp
    QApp = QtWidgets.QApplication.instance()
AttributeError: 'QtGui_cls' object has no attribute 'QApplication'

要安装Qt,我使用brew install python cmake qt(虽然,这可能是Qt5,也许这是问题?)

我的pipenv图如下所示:

scikit-image==0.13.1
  - matplotlib [required: >=1.3.1, installed: 2.0.2]
    - cycler [required: >=0.10, installed: 0.10.0]
      - six [required: Any, installed: 1.11.0]
    - numpy [required: >=1.7.1, installed: 1.13.3]
    - pyparsing [required: >=1.5.6,!=2.0.4,!=2.1.6,!=2.1.2, installed: 2.2.0]
    - python-dateutil [required: Any, installed: 2.6.1]
      - six [required: >=1.5, installed: 1.11.0]
    - pytz [required: Any, installed: 2017.2]
    - six [required: >=1.10, installed: 1.11.0]
  - networkx [required: >=1.8, installed: 2.0]
    - decorator [required: >=4.1.0, installed: 4.1.2]
  - pillow [required: >=2.1.0, installed: 4.2.1]
    - olefile [required: Any, installed: 0.44]
  - PyWavelets [required: >=0.4.0, installed: 0.5.2]
    - numpy [required: >=1.9.1, installed: 1.13.3]
  - scipy [required: >=0.17.0, installed: 0.19.1]
    - numpy [required: >=1.8.2, installed: 1.13.3]
  - six [required: >=1.7.3, installed: 1.11.0]

任何想法可能出错?

1 个答案:

答案 0 :(得分:1)

我通过使用pip3安装PyQt4解决了同样的问题:

sudo pip3 install PyQt4

在PyCharm 2017.3.4中,在我更改解释器设置之前,更改未得到应用:

设置 - &gt;项目: - &gt;项目口译员 - &gt;安装(+) - &gt;可用套餐 - &gt; PyQt4 - &gt;安装包

PyQt4需要Python 3.4。 PyQt5可以与较新版本的Python一起使用,但PyQt5的结构与之前的版本不同。 PyQt4的QtGui模块已被拆分为PyQt5的QtGuiQtPrintSupportQtWidgets模块。 ImageViewer依赖于移动到另一个模块的QFileDialog,并且无法与PyQt5一起使用。