ipython: Why "%matplotlib inline" run correctly but "%pylab" failed?

On my OS(Linux Mint Debian Edition 2), except for the system python(/usr/bin/python) installed by the apt, I also installed the anaconda. But I’ve encounterd a problem running the following code with the anaconda python

# test.py
import matplotlib.pyplot as plt
import numpy as np
x = np.array([0, 1])
plt.scatter(x, x)

The error is

This application failed to start because it could not find or load the
Qt platform plugin “xcb”.

Reinstalling the application may fix this problem.


But if I try with the system python, i.e., /usr/bin/python test.py, it works correctly.

Then I tried the ipythons, of system and of anaconda, the result is same as before: the anaconda ipython kernel died.

And I tried add the ipython magic %matplotlib inline into the code, the anaconda ipython works correctly now. But if I replace the %matplotlib inline with %pylab, the anaconda ipython died again.

Note: I use the python 2.7. System ipython’s version is 2.3, anaconda ipython’s version is 3.2.

Source: linux

Leave a Reply