Please fix pip install, so that plt.show() etc work correctly.
What I do:
- on ubuntu 14.04
- virtualenv ~/env
- source ~/env/bin/activate
- pip install numpy
- pip install matplotlib
- python
- import matplotlib.pyplot as plt
- plt.scatter([3,2,5],[3,4,2])
- plt.show()
What I expect to happen: plot should show
What actually happens: nothing
Other people with similar issue: see this stackoverflow question: http://stackoverflow.com/questions/7534453/matplotlib-does-not-show-my-drawings-although-i-call-pyplot-show
pip is working fine, it is a problem with virtualenv (sort of). By default,
the venv you create can not see the site-packages from the python install
that it copies from. Most likely, you would already have on your linux
system either PyQt or GTK installed to the system’s site-packages. Thus,
when you install matplotlib via pip outside the venv, everything works fine
because those packages can be found by the system python when matplotlib is
built. But in the venv, they can’t be found and so the matplotlib build
falls back to the headless state.
One way to mitigate this is to install the tkinter headers on your system.
Your venv will have access to the tkinter packages (it gets copied over
when the virtual environment gets built) and the tk headers would then be
available globally, regardless of whether you are in the system python or
the venv. Then, when matplotlib is built, it will find tk headers and build
the tkagg backend. The tkagg and macosx backends (and technically, the
lesser known “windowing” backend) are the only backends that need to be
compiled before it can be used.
As a side note, this problem only exists for Linux. pip will install
matplotlib using wheels for Windows and Macs, which would already have the
backends compiled, or would have one of the optional toolkits be a required
dependency.
On Sun, Dec 14, 2014 at 8:13 AM, Hugh Perkins notifications@github.com
wrote: