owlready2
A package for ontology-oriented programming in Python: load OWL 2.0 ontologies as Python objects, modify them, save them, and perform reasoning via HermiT. Includes an optimized RDF quadstore.
What it is and what it does
Owlready2 is a Python framework for working with OWL 2.0 ontologies and RDF knowledge graphs as if they were native Python objects. It provides transparent manipulation of ontology classes, instances, and properties, automatic reasoning and classification via embedded reasoners, and an optimized quadstore backend that can handle large-scale RDF datasets. The package supports multiple serialization formats (NTriples, RDF/XML, OWL/XML), SPARQL querying, and can be used as an object-relational mapper for graph-based data storage.
The module is designed for knowledge representation and semantic reasoning tasks, particularly in biomedical and scientific domains. It includes built-in support for medical terminologies through PyMedTermino2, allows mixing OWL constructs with Python methods on classes, and integrates with RDFlib. The main constraint is that it distributes as source code only, requiring compilation during installation.
Use it for:
- Load and programmatically manipulate biomedical ontologies (UMLS, SNOMED CT) for terminology mapping and knowledge extraction.
- Build semantic knowledge graphs by creating OWL classes and instances in Python, then export to standard RDF/XML formats.
- Query and reason over large RDF datasets using SPARQL and automatic classification with HermiT or Pellet reasoners.
- Use as a graph database alternative for ontology-backed object storage with semantic reasoning capabilities.
- Integrate OWL-based domain models into Python applications while maintaining OWL 2.0 compliance and reasoning.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Owlready2 is a Python module for ontology-oriented programming that loads, manipulates, and reasons over OWL 2.0 ontologies and RDF knowledge graphs, with an embedded optimized quadstore and support for HermiT/Pellet reasoners.
Yes, with conditions. Owlready2 is production-stable, actively maintained, and solves a specific problem—ontology-oriented programming in Python. The copyleft LGPL-3.0-or-later license is acceptable for most open-source projects but requires review for proprietary use. High install friction (source-only distribution requiring compilation) is a real barrier; ensure your environment has a C compiler and development headers. If you need OWL/RDF manipulation, semantic reasoning, or knowledge graph management in Python, it is worth the setup cost.
Install
owlready2 on PyPI
pip
pip install owlready2uv
uv add owlready2poetry
poetry add owlready2Installing owlready2
Before you install
High install friction due to source-only distribution (tar.gz); requires compilation. Actively maintained with recent release (53 days old) and production-stable status, supporting Python 3.6–3.10 and PyPy.
License in practice
Licensed under LGPL-3.0-or-later (copyleft). Derivative works and modifications must be distributed under the same license; proprietary use requires careful review of linking obligations.
Quickstart
from owlready2 import *
onto = get_ontology("http://example.org/ontology.owl")
onto.load()
results = list(default_world.sparql("SELECT * { ?x a owl:Class . }"))
Requires compilation from source (tar.gz); ensure a C compiler and development headers are available.
Verify before relying
- Whether the included HermiT and Pellet reasoners are fully functional or require external setup.
- Performance characteristics and scalability limits beyond the stated 1 billion RDF triples claim.
- Whether PyMedTermino2 submodule for UMLS/DBpedia requires additional dependencies or configuration.
Package facts
| License | LGPL-3.0-or-later (copyleft) |
| Python support | supports the current Python release (>=3.6) |
| Install friction | high — source build required |
| Runtime dependencies | none |
| Maintenance | actively maintained — 53 days since the last release |
| First released | |
| Downloads | 96,791/month — #13,193 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: owlready2-0.51.tar.gz
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
owlrlImplements OWL2 RL Profile and RDFS inference…
unclear · top 5,000 on PyPI
rdflibRDFLib is a Python library for parsing,…
permissive · top 1,000 on PyPI
prontoPronto parses, browses, creates, and exports…
permissive · top 15,000 on PyPI
pyshaclValidates RDF graphs against SHACL shape…
permissive · top 5,000 on PyPI
SPARQLWrapperSPARQLWrapper provides a Python interface to…
unclear · top 5,000 on PyPI
pymanticPymantic parses and queries RDF and semantic…
permissive · top 15,000 on PyPI
pystardogPython client library for querying and managing…
permissive · top 15,000 on PyPI
PyShExPyShEx parses and validates RDF data against…
permissive · top 15,000 on PyPI
CFGraphCFGraph extends rdflib's Graph to read RDF…
permissive · top 15,000 on PyPI
sssomParse, validate, and convert SSSOM (Simple…
permissive · top 15,000 on PyPI