napari: Segfault with Dask and OpenCV

🐛 Bug

To Reproduce

Steps to reproduce the behavior:

import dask, cv2, napari
from skimage import data
with napari.gui_qt():
    _ = napari.view_image(data.astronaut())
  • This happens in both the interactive prompt and by running the script from the command line.
  • Not importing dask resolves the issue
    • I need dask, though 😕/

Expected behavior

The image should be displayed

Environment

napari: 0.2.12
Platform: Darwin-19.4.0-x86_64-i386-64bit
Python: 3.6.8 (v3.6.8:3c6b436a57, Dec 24 2018, 02:04:31) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
Qt: 5.13.2
PySide2: 5.13.2
VisPy: 0.6.4
NumPy: 1.18.1
SciPy: 1.4.1
scikit-image: 0.16.2
Dask: 2.11.0

GL version: 2.1 INTEL-14.5.17
MAX_TEXTURE_SIZE: 16384

Additional context

When I run my script, this output always occurs when importing napari and cv2 together:

objc[2836]: Class QMacAutoReleasePoolTracker is implemented in both /Users/suman/Library/Caches/pypoetry/virtualenvs/pymana-zNasaWCC-py3.6/lib/python3.6/site-packages/cv2/.dylibs/QtCore (0x121ec3700) and /Users/suman/Library/Caches/pypoetry/virtualenvs/pymana-zNasaWCC-py3.6/lib/python3.6/site-packages/PySide2/Qt/lib/QtCore.framework/Versions/5/QtCore (0x125b59700). One of the two will be used. Which one is undefined.
objc[2836]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE is implemented in both /Users/suman/Library/Caches/pypoetry/virtualenvs/pymana-zNasaWCC-py3.6/lib/python3.6/site-packages/cv2/.dylibs/QtCore (0x121ec3778) and /Users/suman/Library/Caches/pypoetry/virtualenvs/pymana-zNasaWCC-py3.6/lib/python3.6/site-packages/PySide2/Qt/lib/QtCore.framework/Versions/5/QtCore (0x125b59778). One of the two will be used. Which one is undefined.
objc[2836]: Class KeyValueObserver is implemented in both /Users/suman/Library/Caches/pypoetry/virtualenvs/pymana-zNasaWCC-py3.6/lib/python3.6/site-packages/cv2/.dylibs/QtCore (0x121ec37a0) and /Users/suman/Library/Caches/pypoetry/virtualenvs/pymana-zNasaWCC-py3.6/lib/python3.6/site-packages/PySide2/Qt/lib/QtCore.framework/Versions/5/QtCore (0x125b597a0). One of the two will be used. Which one is undefined.
objc[2836]: Class RunLoopModeTracker is implemented in both /Users/suman/Library/Caches/pypoetry/virtualenvs/pymana-zNasaWCC-py3.6/lib/python3.6/site-packages/cv2/.dylibs/QtCore (0x121ec37f0) and /Users/suman/Library/Caches/pypoetry/virtualenvs/pymana-zNasaWCC-py3.6/lib/python3.6/site-packages/PySide2/Qt/lib/QtCore.framework/Versions/5/QtCore (0x125b597f0). One of the two will be used. Which one is undefined.

Interestingly, importing dask doesn’t cause any warning.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (11 by maintainers)

Most upvoted comments

Ok good. Yeah I’m going to close this since it’s pretty clear this is an issue with the version of Qt shipped with opencv, which has been reported elsewhere. If anyone stumbles on this issue and it does not work for you to use opencv with pip install opencv-contrib-python-headless or to import cv2 after napari/qtpy, feel free to leave a new comment.

we don’t unfortunately have the [pyqt] option at the moment. So to try this, you will need to:

pip install napari
pip uninstall pyside2 -y
pip install pyqt5

f anyone stumbles on this issue and it does not work for you to use opencv with pip install opencv-contrib-python-headless or to import cv2 after napari/qtpy, feel free to leave a new comment.

At some point we should add this to our docs in maybe a “trouble shooting” section - I just encountered this error and switching to the headless install worked great