1

This simple script:

from gi.repository import Gtk
print "I'm happy"

Runs without problem when running as "Python Run" in PyDev (latest). But when trying to run the debugger, also as "Python Run", something has changed in the environment, and libraries fail to load:

pydev debugger: starting
Traceback (most recent call last):
  File "C:\eclipse\plugins\org.python.pydev_3.2.0.201312292215\pysrc\pydevd.py", line1706, in <module>
    debugger.run(setup['file'], None, None)
  File "C:\eclipse\plugins\org.python.pydev_3.2.0.201312292215\pysrc\pydevd.py", line 1324, in run
    pydev_imports.execfile(file, globals, locals)  #execute the script
  File "C:\Users\jpcaram\Dropbox\CNC\pcbcam\test_gi.py", line 1, in <module>
    from gi.repository import Gtk
  File "C:\WinPython-32\python-2.7.6\lib\site-packages\gi\__init__.py", line 27, in <module>
    from ._gi import _API
ImportError: DLL load failed: The specified module could not be found.

I'm using WinPython-32 registered with Win 7 and, gi and Gtk where installed via pygi-aio-3.10.2-win32_rev12-setup.exe. Everything seems to be working normally outside PyDev/Eclipse.

jpcgt
  • 2,138
  • 2
  • 19
  • 34

1 Answers1

0

I'm not really sure what could be the culprit there.

My suggestion would be first checking if the environment is exactly the same or if there's something different.

I.e.: Use the code:

import os
for key, val in sorted(os.environ.items()):
    print(key)
    vals = sorted(val.split(os.pathsep))
    print('    ' + '\n    '.join(vals))

to get the environment and do the compare (run it in regular and in debug mode, save the results to a file, then select both inside Eclipse > right click > compare with > each other).

p.s.: may be related or not, but I find it strange that you have 'WinPython-32' and then a 'python-2.7.6' version inside.

Fabio Zadrozny
  • 24,814
  • 4
  • 66
  • 78
  • The only difference between environments is that in the debugger PYTHONPATH has an extra entry: 'C:\WinPython-32\python-2.7.6\lib\site-packages\numpy\core' – jpcgt Jan 11 '14 at 04:41
  • I just tried this in PyCharm, which also uses the PyDev debugger, and I works. I wish I could get it to work in Eclipse. Thanks. – jpcgt Jan 12 '14 at 02:58
  • Have you seen: http://stackoverflow.com/questions/15557658/import-errors-with-python-and-gtk-3 or http://stackoverflow.com/questions/13794658/unable-to-import-gtk-after-installing-pygobject – Fabio Zadrozny Jan 12 '14 at 16:54
  • I don't think it is related to the installation of Gtk, as it works okay everywhere except in the PyDev debugger inside Eclipse. Tested to work normally in Eclipse/PyDev (not debugger), PyCharm (normal run and debugger), Spyder (normal run and debugger). – jpcgt Jan 16 '14 at 15:24
  • Can you do the following as a test: download LiClipse (http://brainwy.github.io/liclipse/download.html), install and configure it (using a different workspace from the one you're using now), create that file and run it to see if you have the same error. LiClipse albeit commercial is mostly a PyDev standalone -- you don't need to buy it just to make this test (just checking if it may be some issue in the Eclipse/PyDev installation as LiClipse is a bit better pre-configured). – Fabio Zadrozny Jan 17 '14 at 17:16
  • Just did, with exactly the same results. Running works, debugging fails. How does PyDev call the target file? I see that it uses pydev_imports.execfile(). What does it do? – jpcgt Jan 18 '14 at 03:31
  • In Python 2 that maps to the builtin execfile directly... another thing to check: if you put: `from gi.repository import Gtk;print("At start of pydevd")` in pydevd.py (at eclipse/plugins/org.python.pydev_XXX/pysrc/pydevd.py), and then start a debug session, do you have the same error or it works there? – Fabio Zadrozny Jan 19 '14 at 17:01
  • Just to note, I downloaded pygobjectwin32 here and it worked for me (although not those same versions... do you think you could zip all your winpython32 install, zip it and make it available for me to download to check if it's something related to it?) – Fabio Zadrozny Jan 19 '14 at 17:04
  • Here it is: [link](https://www.dropbox.com/s/3qpnjwp0f7gqquz/WinPython-32.zip). Let me know when you have it so I can remove it. – jpcgt Jan 23 '14 at 01:42