擅长:python、mysql、java
<p>如果你在一个有<code>--no-site-packages</code>的虚拟现实中<code>pip install matplotlib</code>,并且<code>plt.show()</code>没有显示你的情节:</p>
<p>1)要么<code>apt-get</code>安装matplotlib,然后<code>virtualenv --system-site-packages FOLDERNAME</code></p>
<p>2)或者,从<a href="http://www.stevenmaude.co.uk/posts/installing-matplotlib-in-virtualenv" rel="nofollow">this guide</a>:</p>
<pre><code>pip uninstall matplotlib
sudo apt-get install python-gtk2-dev
ln -sf /usr/lib/python2.7/dist-packages/{glib,gobject,cairo,gtk-2.0,pygtk.py,pygtk.pth} $VIRTUAL_ENV/lib/python2.7/site-packages
pip install matplotlib
</code></pre>
<p>指南中还有另一个步骤,但这对我来说不是必需的(在<code>~/.config/matplotlib/matplotlibrc</code>中将后端设置为<code>GTKAgg</code>)</p>