Registry / data / pyshex

pyshex

JSON →
library0.9.0pypypi✓ verified 87d ago

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).

pip install pyshex
INSTALL
IMPORT
SIG · PYSHEX
P
pyshex
datapythonv0.9.0
Install
5.0s avg
Import
2225ms
Disk
32MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.280s · 32.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 5.0s · import 2.170s · 34MB
32MB installed
● package 32MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ShExEvaluator
from pyshex import ShExEvaluator
from pyshex.evaluator import ShExEvaluator
ShExEvaluator moved to top-level in 0.7.x
ShexMaker
from pyshex import ShexMaker

Basic usage: parse an RDF graph, define a ShEx schema, and evaluate whether a node conforms.

from pyshex import ShExEvaluator from rdflib import Graph g = Graph() g.parse("example.ttl", format="turtle") shapes = """PREFIX ex: <http://example.org/> ex:UserShape { ex:name xsd:string ; ex:age xsd:integer }""" evaluator = ShExEvaluator(rdf_graph=g, schema=shapes, focus="http://example.org/user1") result = evaluator.evaluate() print(result)
pyshex --version
Debug
Known issues
breakingIn 0.8.0, rdflib 5/6 compatibility changes may break code relying on older rdflib triples/indexing.
fix
Update rdflib to >=5.0.0 and check for changes in graph iteration.
affects: >=0.8.0
deprecatedShExEvaluator API changed: the 'workspace' parameter is deprecated, use 'rdf_graph' and 'schema' directly.
fix
Replace workspace=... with rdf_graph=..., schema=...
affects: >=0.7.0
gotchaANTLR runtime version must match the version used by pyshex (currently pinned to 4.9). Mismatched ANTLR versions cause parsing errors.
fix
Ensure antlr4-python3-runtime==4.9 is installed: pip install 'antlr4-python3-runtime==4.9'
affects: all
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'antlr4'
ANTLR runtime is missing or wrong version.
fix
pip install 'antlr4-python3-runtime==4.9'
AttributeError: 'Graph' object has no attribute 'triples'
rdflib 5+ changed the API; use 'g.triples((s,p,o))' instead of g.triples.
fix
Replace g.triples(...) with g.triples((subject, predicate, object))
ImportError: cannot import name 'ShExEvaluator' from 'pyshex.evaluator'
Import path changed; ShExEvaluator is now at pyshex directly.
fix
Use: from pyshex import ShExEvaluator
ValueError: Missing 'schema' parameter
ShExEvaluator requires 'schema' and 'rdf_graph' as keyword arguments.
fix
Call as ShExEvaluator(rdf_graph=..., schema=..., focus=...)
Upgrade
Version history
0.9.0latest on PyPI · released May 7, 2026
Audit
Dependencies
rdflibrequiredRequired for RDF graph manipulation
antlr4-python3-runtimerequiredUsed for parsing ShEx schemas
Agent activity
6 hits · last 30 days
node
6
Resources
pyshex — pip install pyshex · libregistry