gpt4 book ai didi

python - 导入错误 : No module named _backend_gdk

转载 作者:太空狗 更新时间:2023-10-29 17:58:06 25 4
gpt4 key购买 nike

我开始深入了解使用 pyGTK+ 使用 python 和 matplotlib 进行交互式绘图。因此我看了一下 example given at the matplotlib website .

这是代码的简短摘录:

#!/usr/bin/env python
"""
Example of embedding matplotlib in an application and interacting with
a treeview to store data. Double click on an entry to update plot
data

"""
import pygtk
pygtk.require('2.0')
import gtk
from gtk import gdk

import matplotlib
matplotlib.use('GTKAgg') # or 'GTK'
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas

from numpy.random import random
from matplotlib.figure import Figure

我尝试在终端中运行此脚本时出现以下错误:

Traceback (most recent call last):
File "gtk_spreadsheet.py", line 15, in <module>
from matplotlib.backends.backend_gtk import FigureCanvasGTK as FigureCanvas
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 33, in <module>
from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gdk.py", line 29, in <module>
from matplotlib.backends._backend_gdk import pixbuf_get_pixels_array
ImportError: No module named _backend_gdk

我安装了 python 2.7 和 pygtk 2.24。

谁能找出错误所在?我认为这可能与某些链接问题有关?

最佳答案

请注意,您需要的 Debian/Ubuntu 软件包不是“pygtk2-devel”,而是“python-gtk2-dev”:

sudo apt-get install python-gtk2-dev

应该在这些平台上修复这个错误。

关于python - 导入错误 : No module named _backend_gdk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14346090/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com