jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.71k stars 4.95k forks source link

%matplotlib qt5 kills the kernel #3205

Open ghost opened 6 years ago

ghost commented 6 years ago

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)
<ipython-input-5-eff513f636fd> in <module>()
----> 1 import matplotlib.pyplot as plt

/Users/jasonkhadka/anaconda2/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
    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 <module>()
     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 <module>()
     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 <module>()
     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 <module>()
     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 <module>()
    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.
ccordoba12 commented 6 years ago

@jkhadka, I already fixed this in ipykernel.

@takluyver, could you release a new version of ipykernel with my fix? Thanks!

ghost commented 6 years ago

@ccordoba12 hey, can you point me to the fix you said? Or will it have to come with new udpate and I should wait till then? Thanks for your reply.

takluyver commented 6 years ago

IPykernel 4.8 is now out. :-)