Python matplotlib';开罗.上下文';错误

Python matplotlib';开罗.上下文';错误,python,matplotlib,typeerror,cairo,Python,Matplotlib,Typeerror,Cairo,在我的virtualenv上运行时,我在终端上编写了这段代码,并通过matplotlib绘图,显示了一个名为“Figure 1”的窗口,其中没有图形/内容,同时抛出“TypeError”: (cv) pi@raspberrypi:~ $ python3 Python 3.5.3 (default, Jan 19 2017, 14:11:04) [GCC 6.3.0 20170124] on linux Type "help", "copyright", "credits" or "licens

在我的virtualenv上运行时,我在终端上编写了这段代码,并通过matplotlib绘图,显示了一个名为“Figure 1”的窗口,其中没有图形/内容,同时抛出“TypeError”:

(cv) pi@raspberrypi:~ $ python3
Python 3.5.3 (default, Jan 19 2017, 14:11:04) 
[GCC 6.3.0 20170124] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> from matplotlib import pyplot as plt
>>> x=[1,2,3,4]
>>> y=[2,4,6,8]
>>> plt.plot(x,y)
[<matplotlib.lines.Line2D object at 0x6fd4ca10>]
>>> plt.show()
TypeError: Couldn't find foreign struct converter for 'cairo.Context'
TypeError: Couldn't find foreign struct converter for 'cairo.Context'
TypeError: Couldn't find foreign struct converter for 'cairo.Context'
TypeError: Couldn't find foreign struct converter for 'cairo.Context'
(cv)pi@raspberrypi:~$python3
Python 3.5.3(默认值,2017年1月19日,14:11:04)
[GCC 6.3.0 20170124]在linux上
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>将numpy作为np导入
>>>从matplotlib导入pyplot作为plt
>>>x=[1,2,3,4]
>>>y=[2,4,6,8]
>>>平面图(x,y)
[]
>>>plt.show()
TypeError:找不到“cairo.Context”的外部结构转换器
TypeError:找不到“cairo.Context”的外部结构转换器
TypeError:找不到“cairo.Context”的外部结构转换器
TypeError:找不到“cairo.Context”的外部结构转换器
我用的是拉斯宾的拉伸版本。我已经用
sudo-pip安装matplotlib
安装了matplotlib,并尝试过,还安装了一些相关的软件包。我能做什么


第二,没有matplotlib库,还有其他方法可以在opencv中绘制图像的直方图吗?

后端设置为什么
plt.get_backend()
是否可以选择更改它,
import matplotlib;matplotlib.use(“TkAgg”)
这会如何改变错误?我的后端是“GTK3Agg”。应用“TkAgg”后,它可以工作(非常感谢!),但在重新打开终端后,它不是永久性的。如何使其永久化?请参见示例。