Matplotlib – ipython notebook – $DISPLAY variable error


I am running IPython notebook on an ubuntu vm. Everything works great so far, except I'm unable to do interactive matplotlib plots.

The error I get is: TclError: no display name and no $DISPLAY environment variable

And I'm just trying to follow these super basic tutorials.

Any tips? I've done some research but nothing seems applicable to running iPython from an ubuntu machine. I know I'm overlooking something obvious.

After speaking with ThomasK about this, it seems I need to run %matplotlib nbaggs following %matplotlib inline from within iPython to get the interactivity from within my VM.

However, interactivity only came available in the latest release of matplotlib (1.4.x) and so I needed to upgrade from 1.3.x.

After running sudo pip install matplotlib --upgrade I got the following error in my .pip_log.

Any advice?

Cleaning up...
  Removing temporary dir /tmp/pip_build_root...
Command python egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/", line 122, in main
    status =, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/", line 278, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/", line 1229, in prepare_files
  File "/usr/lib/python2.7/dist-packages/pip/", line 325, in run_egg_info
    command_desc='python egg_info')
  File "/usr/lib/python2.7/dist-packages/pip/", line 697, in call_subprocess
    % (command_desc, proc.returncode, cwd))
InstallationError: Command python egg_info failed with error code 1 in /tmp/pip_build_root/matplotlib

PLEASE SEE HERE FOR A MUCH BETTER QUESTION: ipython notebook on linux VM running matplotlib interactive with nbagg

Best Solution

Run this before

%matplotlib inline
Related Question