{"id":21792,"library":"pyshex","title":"PyShEx","description":"Python implementation of the Shape Expressions (ShEx) language, used for validating RDF data against shape schemas. Current version 0.8.1, requires Python >=3.6, supports rdflib 5 and 6. Release cadence is sparse (major updates every few months).","status":"active","version":"0.8.1","language":"python","source_language":"en","source_url":"https://github.com/hsolbrig/PyShEx","tags":["shex","shape-expressions","rdf","validation"],"install":[{"cmd":"pip install pyshex","lang":"bash","label":"Standard install"}],"dependencies":[{"reason":"Required for RDF graph manipulation","package":"rdflib","optional":false},{"reason":"Used for parsing ShEx schemas","package":"antlr4-python3-runtime","optional":false}],"imports":[{"note":"ShExEvaluator moved to top-level in 0.7.x","wrong":"from pyshex.evaluator import ShExEvaluator","symbol":"ShExEvaluator","correct":"from pyshex import ShExEvaluator"},{"note":"","wrong":null,"symbol":"ShexMaker","correct":"from pyshex import ShexMaker"}],"quickstart":{"code":"from pyshex import ShExEvaluator\nfrom rdflib import Graph\n\ng = Graph()\ng.parse(\"example.ttl\", format=\"turtle\")\n\nshapes = \"\"\"PREFIX ex: <http://example.org/>\nex:UserShape {\n  ex:name xsd:string ;\n  ex:age xsd:integer\n}\"\"\"\n\nevaluator = ShExEvaluator(rdf_graph=g, schema=shapes, focus=\"http://example.org/user1\")\nresult = evaluator.evaluate()\nprint(result)","lang":"python","description":"Basic usage: parse an RDF graph, define a ShEx schema, and evaluate whether a node conforms."},"warnings":[{"fix":"Update rdflib to >=5.0.0 and check for changes in graph iteration.","message":"In 0.8.0, rdflib 5/6 compatibility changes may break code relying on older rdflib triples/indexing.","severity":"breaking","affected_versions":">=0.8.0"},{"fix":"Replace workspace=... with rdf_graph=..., schema=...","message":"ShExEvaluator API changed: the 'workspace' parameter is deprecated, use 'rdf_graph' and 'schema' directly.","severity":"deprecated","affected_versions":">=0.7.0"},{"fix":"Ensure antlr4-python3-runtime==4.9 is installed: pip install 'antlr4-python3-runtime==4.9'","message":"ANTLR runtime version must match the version used by pyshex (currently pinned to 4.9). Mismatched ANTLR versions cause parsing errors.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"pip install 'antlr4-python3-runtime==4.9'","cause":"ANTLR runtime is missing or wrong version.","error":"ModuleNotFoundError: No module named 'antlr4'"},{"fix":"Replace g.triples(...) with g.triples((subject, predicate, object))","cause":"rdflib 5+ changed the API; use 'g.triples((s,p,o))' instead of g.triples.","error":"AttributeError: 'Graph' object has no attribute 'triples'"},{"fix":"Use: from pyshex import ShExEvaluator","cause":"Import path changed; ShExEvaluator is now at pyshex directly.","error":"ImportError: cannot import name 'ShExEvaluator' from 'pyshex.evaluator'"},{"fix":"Call as ShExEvaluator(rdf_graph=..., schema=..., focus=...)","cause":"ShExEvaluator requires 'schema' and 'rdf_graph' as keyword arguments.","error":"ValueError: Missing 'schema' parameter"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}