i using gobject-introspection in python2.7 on ubuntu raring , run import error while building packages. have isolated minimal set of steps replicate it:
make local directory structure:
gi: __init__.py overrides: __init__.pyput standard boilerplate
from pkgutil import extend_path __path__ = extend_path(__path__, __name__) print __path__, __name__in both
__init__.pyfiles.from directory containing local copy of
gi, run following:python -c "from gi import repository"i error message looks like:
traceback (most recent call last): file "<string>", line 1, in <module> file "/usr/lib/python2.7/dist-packages/gi/repository/__init__.py", line 25, in <module> ..importer import dynamicimporter file "/usr/lib/python2.7/dist-packages/gi/importer.py", line 28, in <module> .module import dynamicmodule file "/usr/lib/python2.7/dist-packages/gi/module.py", line 37, in <module> .overrides import registry importerror: cannot import name registry
any explanation? can't find decent documentation of intended behavior because gobject-introspection seems poorly documented project. appreciated!
from python documentation:
the
__init__.pyfiles required make python treat directories containing packages; done prevent directories common name, such string, unintentionally hiding valid modules occur later on module search path.
simply having __init__.py files accessible running directory, telling interpreter that implementation of gi module. usage of main gi module not go correctly.
now, why print error coming /usr/lib ? because gi found in local/gi, gi.repository found in /usr/lib/python2.7/dist-packages/gi/repository . running /usr/lib/python2.7/dist-packages/gi/repository/__init__.py. there, imports other submodules correctly, when tries import overrides finds local stub in gi/overrides. stub not define registry, have fail.
try , put registry='dumb_string' in gi/overrides/__init__.py , see error gone.
Comments
Post a Comment