ImportError when I import FigureCanvasGTKAgg—seeking advice!

Hi all,

I am new to the forum and to all things PyGTK and matplotlib, so go easy on me, please.

A colleague created a Python program that uses matplotlib and GTK. I wanted to be able run her program on my MacBook (OS X 10.6.7). I used macports to update/obtain Python 2.7, matplotlib 1.0.1, and PyGTK 2.22.0. (I also obtained ipython, if anyone cares.)

After all of this, my colleague’s program hits a snag when I try to run it; here is the traceback:

**Traceback (most recent call last): File "main.py", line 5, in from interface import Interface, Display, Controls File "/Users/thecommexokid/Documents/CurrentProjects/Honors/DoubleSlit/interface.py", line 5, in <module> from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module> from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\ File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 28, in <module> from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK File "/opt/local/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**
I believe I may be having the same problem as the user in this post, but I am enough of a novice that the solution that was suggested there just sounds like gobbletygook to me. If anybody wants to elaborate on that so I can try it out, please do.

Anyhow, any advice anyone has on how to overcome this problem and get her program running on my machine would be greatly appreciated. As I said, I am new to these things, and I don’t really understand the interplay between Python, PyGTK, and matplotlib, so if there’s crucial information I haven’t provided, or if this isn’t the best forum in which to be asking this question, let me know.

Thanks in advance for the help.

···

PS: I originally posted this question at the GTK+ Forums (thread), but it seemed as though this might be the more appropriate forum. I’ll be sure to keep both threads updated with any developments.


View this message in context: ImportError when I import FigureCanvasGTKAgg—seeking advice!

Sent from the matplotlib - users mailing list archive at Nabble.com.

I found a solution after all, from the thread I mentioned in the original post, which turned out not to be as cryptic as I had thought.

Just as the answerer there suggested, I had PyGTK but matplotlib wasn’t recognizing it during build; when I tried building from source instead of using macports this was made clear in the build output.

As he said, I searched my computer to find a file called pygtk-2.0.pc, and added the directory it was in to the system variable PKG_CONFIG_PATH. After I did that, the build was successful and I had no further problems!

Thanks to everyone who may have read my post, but I would up figuring this one out on my own.

···

thecommexokid wrote:

Hi all,

I am new to the forum and to all things PyGTK and matplotlib, so go easy on me, please.

A colleague created a Python program that uses matplotlib and GTK. I wanted to be able run her program on my MacBook (OS X 10.6.7). I used macports to update/obtain Python 2.7, matplotlib 1.0.1, and PyGTK 2.22.0. (I also obtained ipython, if anyone cares.)

After all of this, my colleague’s program hits a snag when I try to run it; here is the traceback:

**Traceback (most recent call last): File "main.py", line 5, in from interface import Interface, Display, Controls File "/Users/thecommexokid/Documents/CurrentProjects/Honors/DoubleSlit/interface.py", line 5, in <module> from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module> from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\ File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py", line 28, in <module> from matplotlib.backends.backend_gdk import RendererGDK, FigureCanvasGDK File "/opt/local/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**
I believe I may be having the same problem as the user in this post, but I am enough of a novice that the solution that was suggested there just sounds like gobbletygook to me. If anybody wants to elaborate on that so I can try it out, please do.

Anyhow, any advice anyone has on how to overcome this problem and get her program running on my machine would be greatly appreciated. As I said, I am new to these things, and I don’t really understand the interplay between Python, PyGTK, and matplotlib, so if there’s crucial information I haven’t provided, or if this isn’t the best forum in which to be asking this question, let me know.

Thanks in advance for the help.


PS: I originally posted this question at the GTK+ Forums (thread), but it seemed as though this might be the more appropriate forum. I’ll be sure to keep both threads updated with any developments.


View this message in context: Re: ImportError when I import FigureCanvasGTKAgg—seeking advice!

Sent from the matplotlib - users mailing list archive at Nabble.com.