{"id":21763,"library":"pymantic","title":"Pymantic","description":"Pymantic is a Semantic Web and RDF library for Python, providing parsers, serializers, and SPARQL client support. The latest version is 1.0.1 (released 2024) with slow release cadence. It supports RDF/XML, Turtle, JSON-LD, TriG, and N-Triples formats.","status":"active","version":"1.0.1","language":"python","source_language":"en","source_url":"https://github.com/norcalrdf/pymantic/","tags":["semantic-web","rdf","turtle","sparql","json-ld"],"install":[{"cmd":"pip install pymantic","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"Parsing library used for Turtle and other RDF syntaxes","package":"lark","optional":false},{"reason":"YAML support for configuration","package":"PyYAML","optional":true},{"reason":"HTTP client for SPARQL endpoints","package":"requests","optional":true}],"imports":[{"note":"","symbol":"SPARQLClient","correct":"from pymantic.sparql import SPARQLClient"},{"note":"","symbol":"Graph","correct":"from pymantic.io import Graph"},{"note":"","symbol":"RDFXMLParser","correct":"from pymantic.io import RDFXMLParser"},{"note":"","symbol":"TurtleParser","correct":"from pymantic.io import TurtleParser"},{"note":"","symbol":"JSONLDParser","correct":"from pymantic.io import JSONLDParser"},{"note":"","symbol":"TriGSerializer","correct":"from pymantic.io import TriGSerializer"}],"quickstart":{"code":"from pymantic.io import Graph\nfrom pymantic.sparql import SPARQLClient\n\n# Create a graph and parse a Turtle file\ngraph = Graph()\ngraph.parse('example.ttl', format='turtle')\nprint(f\"Parsed {len(graph.triples)} triples\")\n\n# Query a SPARQL endpoint\nclient = SPARQLClient('http://dbpedia.org/sparql')\nresults = client.query('SELECT * WHERE {?s ?p ?o} LIMIT 10')\nfor result in results['results']['bindings']:\n    print(result)","lang":"python","description":"Basic usage: parse a Turtle file and query a SPARQL endpoint."},"warnings":[{"fix":"Use `from pymantic.sparql import SPARQLClient` etc. Update imports per new package structure.","message":"Version 1.0.0 dropped Python 2.x support and restructured packaging. Import paths changed from old patterns like `from pymantic import sparql`.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure you use compatible syntax; lark may have stricter parsing. Update Turtle files if needed.","message":"The `lepl`-based parsers were replaced by `lark` in v0.2.0. Old code relying on `lepl` behavior may break.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Install `PyYAML` if needed: `pip install PyYAML`. Use `graph.parse('file.jsonld', format='json-ld')`.","message":"Parsing JSON-LD requires the `json-ld` optional dependency? Actually the library supports JSON-LD but may need `PyYAML` or extra care. Check documentation for exact parsing options (e.g., base URI).","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":"Use `from pymantic.sparql import SPARQLClient`.","cause":"Old import path `from pymantic import SPARQLClient` no longer works after restructuring in v1.0.0.","error":"ImportError: cannot import name 'SPARQLClient' from 'pymantic'"},{"fix":"Ensure you are using `from pymantic.io import Graph` and call `graph.parse('file', format='...')`. For in-memory, create with `Graph()` then parse.","cause":"`Graph.parse` method requires the graph to be created with a filename or explicitly parsed. In older versions, Graph had different API.","error":"AttributeError: 'Graph' object has no attribute 'parse'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}