Installation¶
This guide covers installing CIMantic Graphs from PyPI, and from source with UV for development.
Prerequisites¶
- Python 3.10 or newer (tested on 3.10 to 3.14) - Download Python
- pip, or UV for a source install
Installing from PyPI¶
This installs CIM-Graph and the cimprofiles package with the CIM profiles. It is all you need to read and write CIM XML and JSON-LD files.
Database Drivers¶
Database drivers are optional extras. Install the extra for each connection you use:
| Extra | Installs | For |
|---|---|---|
sparql |
SPARQLWrapper | BlazegraphConnection, GraphDBConnection |
neo4j |
neo4j | Neo4jConnection |
mysql |
mysql-connector-python | MySQLConnection |
gridappsd |
gridappsd-python | GridappsdConnection |
rdflib |
rdflib, oxrdflib | RDFlibConnection |
all |
all of the above |
Using a connection without its driver raises an ImportError that names the extra to install.
Verify Installation¶
After installation, check the installed versions and create a CIM object:
from importlib.metadata import version
import cimprofiles.cim17.cimhub_2023 as cim
print('cim-graph', version('cim-graph'))
print('cim-profiles', version('cim-profiles'))
breaker = cim.Breaker(name='test_breaker', open=False)
print(f'Created breaker {breaker.name}, open: {breaker.open}')
cim-graph 0.6.1 cim-profiles 0.2.0 Created breaker test_breaker, open: False
Install UV¶
Linux, macOS, and WSL2:
Windows PowerShell:
With pip:
Check that UV is installed with uv --version.
Clone the Repository¶
Development happens on the develop branch; main holds the latest release:
Install with UV¶
This command:
1. Creates a virtual environment in .venv/ (if it does not exist)
2. Installs the dependencies pinned in uv.lock
3. Installs CIMantic Graphs in editable mode
4. Installs the dev dependency group (pytest, pre-commit, ipykernel, ...)
The dev group is not published with the package, so pip install "cim-graph[dev]" does not exist. To add database drivers, add their extras:
Activate the Virtual Environment¶
Linux, macOS, and WSL2:
Windows PowerShell:
Windows Command Prompt:
You should see (.venv) at the beginning of your command prompt. Alternatively, prefix commands with uv run (e.g. uv run python script.py) to run them in the environment without activating it. The Verify Installation cell above also checks a source install.
Common UV Commands¶
| Task | Command |
|---|---|
| Add a dependency | uv add <package-name> |
| Add a development dependency | uv add --dev <package-name> |
| Upgrade the locked dependencies | uv sync --upgrade |
| Run a command in the environment | uv run python script.py, uv run pytest |
Build the wheel and source distribution into dist/ |
uv build |
A built wheel can be installed in another environment:
See Contributing for running the tests and the pre-commit hooks.
Next Steps¶
Now that you have CIMantic Graphs installed, you can:
- Try the Quick Start - See Overview
- Learn the library structure - See Structure
- Work with CIM profiles - See Profiles Overview
- Connect to databases - See Databases Overview
- Build graph models - See Graph Models
Common Issues¶
ModuleNotFoundError: No module named 'cimgraph'
- Make sure you activated the virtual environment, or use uv run
- Run uv sync again
ImportError: BlazegraphConnection needs 'SPARQLWrapper', from the 'sparql' extra
- Install the extra the message names: pip install "cim-graph[sparql]", or uv sync --extra sparql in a source install
uv: command not found
- Restart your terminal, or add UV to your PATH
Errors from dependencies
- Check that you have Python 3.10 or newer
- Run uv sync --upgrade to update the dependencies
<style>
['pre { line-height: 125%; }\ntd.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\nspan.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }\ntd.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\nspan.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }\n.highlight-ipynb .hll { background-color: var(--jp-cell-editor-active-background) }\n.highlight-ipynb { background: var(--jp-cell-editor-background); color: var(--jp-mirror-editor-variable-color) }\n.highlight-ipynb .c { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment */\n.highlight-ipynb .err { color: var(--jp-mirror-editor-error-color) } /* Error */\n.highlight-ipynb .k { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword */\n.highlight-ipynb .o { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator */\n.highlight-ipynb .p { color: var(--jp-mirror-editor-punctuation-color) } /* Punctuation */\n.highlight-ipynb .ch { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Hashbang */\n.highlight-ipynb .cm { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Multiline */\n.highlight-ipynb .cp { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Preproc */\n.highlight-ipynb .cpf { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.PreprocFile */\n.highlight-ipynb .c1 { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Single */\n.highlight-ipynb .cs { color: var(--jp-mirror-editor-comment-color); font-style: italic } /* Comment.Special */\n.highlight-ipynb .kc { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Constant */\n.highlight-ipynb .kd { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Declaration */\n.highlight-ipynb .kn { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Namespace */\n.highlight-ipynb .kp { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Pseudo */\n.highlight-ipynb .kr { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Reserved */\n.highlight-ipynb .kt { color: var(--jp-mirror-editor-keyword-color); font-weight: bold } /* Keyword.Type */\n.highlight-ipynb .m { color: var(--jp-mirror-editor-number-color) } /* Literal.Number */\n.highlight-ipynb .s { color: var(--jp-mirror-editor-string-color) } /* Literal.String */\n.highlight-ipynb .ow { color: var(--jp-mirror-editor-operator-color); font-weight: bold } /* Operator.Word */\n.highlight-ipynb .pm { color: var(--jp-mirror-editor-punctuation-color) } /* Punctuation.Marker */\n.highlight-ipynb .w { color: var(--jp-mirror-editor-variable-color) } /* Text.Whitespace */\n.highlight-ipynb .mb { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Bin */\n.highlight-ipynb .mf { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Float */\n.highlight-ipynb .mh { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Hex */\n.highlight-ipynb .mi { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Integer */\n.highlight-ipynb .mo { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Oct */\n.highlight-ipynb .sa { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Affix */\n.highlight-ipynb .sb { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Backtick */\n.highlight-ipynb .sc { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Char */\n.highlight-ipynb .dl { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Delimiter */\n.highlight-ipynb .sd { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Doc */\n.highlight-ipynb .s2 { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Double */\n.highlight-ipynb .se { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Escape */\n.highlight-ipynb .sh { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Heredoc */\n.highlight-ipynb .si { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Interpol */\n.highlight-ipynb .sx { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Other */\n.highlight-ipynb .sr { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Regex */\n.highlight-ipynb .s1 { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Single */\n.highlight-ipynb .ss { color: var(--jp-mirror-editor-string-color) } /* Literal.String.Symbol */\n.highlight-ipynb .il { color: var(--jp-mirror-editor-number-color) } /* Literal.Number.Integer.Long */']
</style>