Re: Using Windows, Eclipse, Python - gtk not importing

On Tue, 31 Jul 2012 16:31:41 -0700, Mark Tiddens wrote:
So, maybe I need to do something to get Eclipse or Python to find gtk?

- In Eclipse's menu, go to "Window" > "Preferences" > "PyDev" > "Interpreter - Python" - In the "Python interpreters" list, select the Python interpreter you want to configure (this example assumes Python 2.7 installed into C:\bin\Python27, adjust as needed) - In the bottom notebook, go to the "Environment" tab and click the "New..." button - Set "Name:" to PATH and "Value:" to C:\bin\Python27\Lib\site-packages\gtk-2.0\runtime\bin;%PATH% and click the "OK" button. The "Value:" part points to the bin directory of your GTK+ bundle (this example assumes the PyGTK All-in-one installer which already comes
  with an appropriate GTK+ bundle out of the box).
- In the bottom notebook, go to the "Forced Builtins" tab and click the "New..." button - Set "Builtin to add" to cairo,glib,gobject,gio,atk,pango,pangocairo,gtk,gtk.gdk,rsvg,gtksourceview2,goocanvas
  and click the "OK" button.
- Back in the "Preferences" dialog, click the "OK" button and wait for PyDev to update its
  symbol database.

So, the first part (setting PATH) answers your question, the second
part (setting forced builtins) ensures PyDev's more advanced features
like code completion function correctly for PyGTK's C extension modules
and works for Eclipse on Windows and Linux equally well.

Note: sometimes PyDev fails to notice its symbol database has been updated and various combinations of restarting Eclipse, right-clicking your PyDev project and selecting "PyDev" > "Remove error markers" and "PyDev" > "Code analysis" are needed before the Python editor stops showing "Unresolved import" errors etc...
Through the years this seems to have happened for some combinations of
the Eclipse platform and PyDev version. It always eventually starts working though and once it does, PyDev is a joy to use. Especially its debugger, which
has nothing even remotely competing with it imho :)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]