Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

If rdflib has been imported, new_object_graph() raises ImportError #22

Open
dswisher opened this issue Sep 19, 2018 · 1 comment
Open

Comments

@dswisher
Copy link

Sample code:

import pinject
import rdflib

foo = pinject.new_object_graph()

Running this results in the following traceback:

Traceback (most recent call last):
  File "bug.py", line 4, in <module>
    foo = pinject.new_object_graph()
  File "/Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/site-packages/pinject/object_graph.py", line 105, in new_object_graph
    found_classes = finding.find_classes(modules, classes)
  File "/Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/site-packages/pinject/finding.py", line 32, in find_classes
    all_classes |= _find_classes_in_module(module)
  File "/Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/site-packages/pinject/finding.py", line 47, in _find_classes_in_module
    for member_name, member in inspect.getmembers(module):
  File "/Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/inspect.py", line 252, in getmembers
    value = getattr(object, key)
  File "/Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/_vendor/six.py", line 92, in __get__
    result = self._resolve()
  File "/Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/_vendor/six.py", line 115, in _resolve
    return _import_module(self.mod)
  File "/Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/site-packages/pkg_resources/_vendor/six.py", line 82, in _import_module
    __import__(name)
ImportError: dlopen(/Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/gdbm.so, 2): Symbol not found: _gdbm_errno
  Referenced from: /Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/gdbm.so
  Expected in: /usr/local/opt/gdbm/lib/libgdbm.4.dylib
 in /Users/bob/.pyenv/versions/2.7.13/Python.framework/Versions/2.7/lib/python2.7/lib-dynload/gdbm.so

Environment:

  • rdflib 4.2.2
  • pinject 0.10.2
  • python 2.7.13 (MacOS) and 2.7.14 (Amazon Linux)

As a workaround, I'm passing a list of modules to new_object_graph to exclude rdflib, and that seems to be working so far.

Thank you for this awesome library. Other than this one small hiccup, it has been working very well, doing exactly what I would expect it to do.

@ghost
Copy link

ghost commented Jul 26, 2020

As a workaround, I'm passing a list of modules to new_object_graph to exclude rdflib, and that seems to be working so far.

Can you post a gist example of this? It's not obvious to me from the method signature how to do this.

UPDATE

Answering my own question. This may be different for you but for me the solution was to scope to the "current" module.

pinject.new_object_graph(modules=[sys.modules[__name__]])

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant