I am unable to import pylab
using the latest version of Anaconda (Linux 64 bit). Other packages seem to work fine. (Note: I don\'t have sudo
access
Following worked for me
import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pylab as pl
Just had this problem and it was related to which qt backend matplotlib was trying to use, try:
import PyQt4
If you don't have PyQt4 you probably have PySide
import PySide
If this is the case you need to set the matplotlib.rcParams['backend.qt4'] == 'PySide'
not 'PyQt4'
. You can also do this in your matplotlibrc file (~/.matplotlib/matplotlibrc)
# find and change line:
backend.qt4 : PySide
Note: if you don't have the matplotlibrc file you can copy it from the matplotlib source directory
import os
import matplotlib
mpl_dir = os.path.dirname(matplotlib.__file__)
os.system("cp {}/mpl-data/matplotlibrc ~/.matplotlib/".format(mpl_dir))