博主使用的时ubuntu16.04下的sublime text3配置python2运行环境,已经成功安装numpy,scipy,matplotlib环境,在测试代码
`import numpy as np
from scipy.stats import beta
from matplotlib.pyplot import hist, plot, show
obs = beta.rvs(5, 5, size=2000) # 2000 observations
hist(obs, bins=40, normed=True)
grid = np.linspace(0.01, 0.99, 100)
plot(grid, beta.pdf(grid, 5, 5), ‘k-‘, linewidth=2)
show()
TypeError: Couldn’t find foreign struct converter for ‘cairo.Context’`
时,遇到了以下问题:
并且弹出来一个空白的figure图框
经过’呕心沥血’的探索,终于找到了解决方案:
I assume you have installed the pip matplotlib, there is a directory in you root called ~ /. matplotlib. Create a file called matplotlibrc there and following code
~ / .matplotlib / Matplotlibrc
backend: TkAgg
就是你先进入你的home目录,按ctrl+h显示所有隐藏文件夹,找到一个叫matplotlib的文件夹,