{"id":27331,"library":"rdflib-shim","title":"rdflib-shim","description":"rdflib-shim is a compatibility layer that smooths over breaking changes between rdflib 5 and 6, allowing code written for rdflib 5 to work with rdflib 6 without modification. Version 1.0.3 (latest) requires Python >=3.7. The library is maintained but low-churn (last release 2022).","status":"active","version":"1.0.3","language":"python","source_language":"en","source_url":"https://github.com/RDFLib/rdflib-shim","tags":["rdflib","shim","compatibility","migration"],"install":[{"cmd":"pip install rdflib-shim","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency; shim patches rdflib's public API to restore rdflib 5 behavior.","package":"rdflib","optional":false}],"imports":[{"note":"The shim is imported before importing rdflib. No common wrong import reported.","wrong":"","symbol":"rdflib_shim","correct":"import rdflib_shim"}],"quickstart":{"code":"import rdflib_shim\nfrom rdflib import Graph, URIRef, Literal\n\ng = Graph()\ng.parse('http://example.org/test.ttl', format='turtle')\nfor s, p, o in g:\n    print(s, p, o)\n","lang":"python","description":"Import the shim first, then use rdflib as usual with rdflib 6."},"warnings":[{"fix":"Always put `import rdflib_shim` as the very first import in your module.","message":"The shim must be imported before any rdflib imports. If rdflib is imported first, the patching won't apply.","severity":"gotcha","affected_versions":"all"},{"fix":"For new code, consider writing directly against rdflib 6 APIs and skip the shim.","message":"rdflib-shim may not be needed for new projects targeting rdflib 6+ directly. Its primary purpose is to ease migration from rdflib 5.","severity":"deprecated","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Add `import rdflib_shim` before `import rdflib` to restore the old behavior.","cause":"In rdflib 6, the RDF namespace is no longer available under rdflib.RDF; it moved to rdflib.namespace.","error":"AttributeError: module 'rdflib' has no attribute 'RDF'"},{"fix":"Use `from rdflib.term import *` or import the shim first.","cause":"rdflib 6 changed internal module structure. Some direct references to rdflib.term fail.","error":"AttributeError: module 'rdflib' has no attribute 'term'"},{"fix":"Either use `from rdflib.term import BNode` or install/import rdflib-shim.","cause":"In rdflib 6, BNode is not directly exported from rdflib.__init__; it's in rdflib.term.","error":"ImportError: cannot import name 'BNode' from 'rdflib'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}