我正在尝试在我的virtualenv中(在控制台中)运行一个简单的matplotlib示例。以下是代码:
import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
radius = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
area = [3.14159, 12.56636, 28.27431, 50.26544, 78.53975, 113.09724]
plt.plot(radius, area)
plt.show()
然而, 当我运行此程序时,出现以下错误:
导入错误: Gtk* 后端需要安装 pygtk.
现在有趣的事情开始了。我尝试使用 pip 安装 pygtk,但它抛出以下错误:
********************************************************************
* Building PyGTK using distutils is only supported on windows. *
* To build PyGTK in a supported way, read the INSTALL file. *
********************************************************************
Complete output from command python setup.py egg_info:
********************************************************************
我已经查阅了 INSTALL
文件,上面写着尝试使用命令 ./configure; make; make install
。然而,我不确定如何在 virtualenv 环境下执行这些操作。我应该在哪里解压 pygtk 的源文件以便在 virtualenv 中安装。