jupyter / jupyter/notebook

%matplotlib qt5 kills the kernel

Open
#3,205 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
13.3k
Forks
5.8k
Avg merge
6d 11h
Merged PRs (30d)
7

Description

Hi,

I recently changed my computer,

From

```
macOS Sierra 10.12.6
conda 4.3.30
Jupyter 4.1.0
matplotlib 1.5.1
Python 2.7.11 | Annaconda custom(x86_64) [GCC 4.2.1 (Apple Inc. build 5577) on darwin
```
To
```
High Sierra 10.13.2
Jupyter 4.4.0
conda 4.3.30
matplotlib 2.1.1
Python 2.7.14 |Anaconda custom (64-bit)| (default, Dec 7 2017, 11:07:58)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
```

I had several problem with running my old plotting code, so I tried changing the backend but still problems persist,
like in `macosx backend` plot in interactive window not opening.
Transparency not working for `tkAgg backend`

Now i trying to switch to `qt5` but everytime i do `%matplotlib qt5` it kills the kernel and I get following output.
```
objc[35078]: Class RunLoopModeTracker is implemented in both /usr/local/opt/qt/lib/QtCore.framework/Versions/5/QtCore (0x10a645368) and /Users/username/anaconda2/lib/libQt5Core.5.6.2.dylib (0x10f19d8b8). One of the two will be used. Which one is undefined.
QObject::moveToThread: Current thread (0x7fe8d965d030) is not the object's thread (0x7fffb0f64340).
Cannot move to target thread (0x7fe8d965d030)

You might be loading two sets of Qt binaries into the same process. Check that all plugins are compiled against the right Qt binaries. Export DYLD_PRINT_LIBRARIES=1 and check that only one set of binaries are being loaded.
This application failed to start because it could not find or load the Qt platform plugin "cocoa"
in "".

Available platform plugins are: cocoa, minimal, offscreen.

Reinstalling the application may fix this problem.
```

Also,

`print os.environ.get('QT_API')`
`>> None`

--------------
Update :
I unisntalled qt from `brew` `brew uninstall qt` and now I can do `%matplotlib qt5` without crashing the kernel.

But now I cannot import `pyplot`.

`import matplotlib.pyplot as plt`

```
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in ()
----> 1 import matplotlib.pyplot as plt

/Users/jasonkhadka/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.py in ()
113
114 from matplotlib.backends import pylab_setup
--> 115 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
116
117 _IP_REGISTERED = None

/Users/jasonkhadka/anaconda2/lib/python2.7/site-packages/matplotlib/backends/__init__.pyc in pylab_setup()
30 # imports. 0 means only perform absolute imports.
31 backend_mod = __import__(backend_name,
---> 32 globals(),locals(),[backend_name],0)
33
34 # Things we pull in from all backends

/Users/jasonkhadka/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py in ()
14
15 from .backend_agg import FigureCanvasAgg
---> 16 from .backend_qt5 import QtCore
17 from .backend_qt5 import QtGui
18 from .backend_qt5 import FigureManagerQT

/Users/jasonkhadka/anaconda2/lib/python2.7/site-packages/matplotlib/backends/backend_qt5.py in ()
24
25 from matplotlib.widgets import SubplotTool
---> 26 import matplotlib.backends.qt_editor.figureoptions as figureoptions
27
28 from .qt_compat import (QtCore, QtGui, QtWidgets, _getSaveFileName,

/Users/jasonkhadka/anaconda2/lib/python2.7/site-packages/matplotlib/backends/qt_editor/figureoptions.py in ()
18 import matplotlib
19 from matplotlib import cm, markers, colors as mcolors
---> 20 import matplotlib.backends.qt_editor.formlayout as formlayout
21 from matplotlib.backends.qt_compat import QtGui
22

/Users/jasonkhadka/anaconda2/lib/python2.7/site-packages/matplotlib/backends/qt_editor/formlayout.py in ()
54
55 from matplotlib import colors as mcolors
---> 56 from matplotlib.backends.qt_compat import QtGui, QtWidgets, QtCore
57
58

/Users/jasonkhadka/anaconda2/lib/python2.7/site-packages/matplotlib/backends/qt_compat.py in ()
126 if QT_API == QT_API_PYQT5:
127 try:
--> 128 from PyQt5 import QtCore, QtGui, QtWidgets
129 _getSaveFileName = QtWidgets.QFileDialog.getSaveFileName
130 except ImportError:

ImportError: cannot import name QtCore```

where as `import matplotlib` works fine.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `%matplotlib qt5` and the subsequent `import matplotlib.pyplot as plt` failure in the reported macOS, Python, Jupyter, and matplotlib environment. Read the backend_qt5.py and qt_compat.py paths shown in the traceback, then verify that the Qt backend loads consistently; done means the kernel remains alive and pyplot imports successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter-notebook, macos, matplotlib, python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.