1

I have a python module and a unit test for it. When i run the unit test i get this:

flumotion
  test
    test_common_gstreamer ...                                           [ERROR]

===============================================================================
[ERROR]
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 660, in loadByNames
    things.append(self.findByName(name))
  File "/usr/lib/python2.7/dist-packages/twisted/trial/runner.py", line 470, in findByName
    return reflect.namedAny(name)
  File "/usr/lib/python2.7/dist-packages/twisted/python/reflect.py", line 464, in namedAny
    topLevelPackage = _importAndCheckStack(trialname)
  File "/flumotion/flumotion/test/test_common_gstreamer.py", line 20, in <module>
    from gi.repository import Gst
  File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 23, in <module>
    from ._gi import _API, Repository
exceptions.ImportError: could not import gobject (error was: ImportError('When using gi.repository you must not import static modules like "gobject". Please change all occurrences of "import gobject" to "from gi.repository import GObject".',))

flumotion.test.test_common_gstreamer

I know the error is self explanatory, but i can't find where the "import gobject" happens, so i've been advised to make an import hook that will print any time something is doing an import. I don't know where and how to implement the hook, i've only read something about import hooks here http://xion.org.pl/2012/05/06/hacking-python-imports/ . Any help is appreciated

10001a
  • 53
  • 1
  • 6
  • have you tried a simple `grep -in "import gobject" path/to/site-packages` ? – tike Jun 19 '13 at 14:30
  • I haven't. How can i try that? – 10001a Jun 19 '13 at 14:33
  • find the place location of your site-packages directory (usually /usr/lib/python2.7/site-packages, replace 2.7 with your python version), then open a shell and type the highlighted command replacing path/to/ with your path and hit enter. – tike Jun 19 '13 at 14:36
  • Ubuntu 12.04 (Precise) – 10001a Jun 19 '13 at 14:38
  • `grep -in "import gobject" /usr/lib/python{VERSION}/site-packages`, to find your python version type `python -V`, the first to digits with a dot in the middle – tike Jun 19 '13 at 14:41
  • I just realized, I made a mistake, grep doesn't work recursively, use `find /usr/lib/python2.7/site-packages -iname "*.py" -exec grep -in "import gobject" {} +`, replacing 2.7 with your python version again. Sorry. Output should be filename:line "text in this line" – tike Jun 19 '13 at 14:47
  • I don't have a site-packages, tho i have dist-packages, but grep doesn't return anything EDIT: I just saw your last comment :)) , this works – 10001a Jun 19 '13 at 14:47
  • then try dist-packages or the hole /usr/lib/python directory ;-) – tike Jun 19 '13 at 14:50
  • maybe you want to answer your question after you found the troublemaker and/or inform it's developers. – tike Jun 19 '13 at 14:57

0 Answers0