Registry / data / python-libsbml

python-libsbml

JSON →
library5.21.1pypypi✓ verified 87d ago

Python bindings for LibSBML, a library for reading, writing, and manipulating SBML (Systems Biology Markup Language) documents. This package provides the libsbml module, which wraps the C++ library SBML API with Python objects. Version 5.21.1 is current; releases follow the upstream LibSBML releases.

pip install python-libsbml
INSTALL
IMPORT
SIG · PYTHON-LIBSBML
P
python-libsbml
datapythonv5.21.1
Install
2.3s avg
Import
Disk
61MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.21.1 · 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
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.3s · import 0.000s · 63MB
61MB installed
● package 61MB
Code
Verified usage

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

libsbml
import libsbml
Top-level module name is 'libsbml' (lowercase). No subpackage needed.

Create an SBML Document, write to file, and read it back. Checks for operation success and errors.

import libsbml import sys document = libsbml.SBMLDocument(3, 2) # SBML Level 3 Version 2 model = document.createModel() model.setId("my_model") # Write to file writer = libsbml.SBMLWriter() result = writer.writeSBML(document, "output.xml") if result != libsbml.LIBSBML_OPERATION_SUCCESS: print("Error writing SBML") sys.exit(1) # Read back reader = libsbml.SBMLReader() document2 = reader.readSBML("output.xml") if document2.getNumErrors() > 0: print("Errors encountered:") document2.printErrors()
Debug
Known issues
breakingThe package name on PyPI is 'python-libsbml', but the import is 'libsbml'. Do not use 'import sbml' or 'import libSBML'.
fix
Use 'import libsbml'.
affects: all
gotchaSBMLDocument constructor takes (level, version) as arguments, but the default is (2, 4) in older LibSBML versions. Always specify if you need a specific SBML level.
fix
Explicitly pass level and version when creating a new document: libsbml.SBMLDocument(3, 2)
affects: all
gotchaError handling: writeSBML returns an integer status code, not a boolean. Checking 'if result:' may be misleading because LIBSBML_OPERATION_SUCCESS is 0 (falsy).
fix
Compare to libsbml.LIBSBML_OPERATION_SUCCESS explicitly: if result != libsbml.LIBSBML_OPERATION_SUCCESS.
affects: all
Errors
Common errors & fixes
ImportError: No module named libsbml
Package not installed or wrong Python environment.
fix
Install with: pip install python-libsbml. Ensure activating the correct virtual environment.
AttributeError: module 'libsbml' has no attribute 'SBMLDocument'
This can happen if there is a name collision: the variable 'libsbml' is redefined or overshadowed.
fix
Do not assign to the name 'libsbml' after importing. Use a different variable for your document: doc = libsbml.SBMLDocument()
Upgrade
Version history
5.21.1latest on PyPI · released Mar 9, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
6 hits · last 30 days
node
6
Resources
python-libsbml — pip install python-libsbml · libregistry