{"id":21820,"library":"python-libsbml","title":"python-libsbml","description":"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.","status":"active","version":"5.21.1","language":"python","source_language":"en","source_url":"https://github.com/sbmlteam/libsbml","tags":["SBML","systems biology","modeling","bioinformatics"],"install":[{"cmd":"pip install python-libsbml","lang":"bash","label":"PyPI install"}],"dependencies":[],"imports":[{"note":"Top-level module name is 'libsbml' (lowercase). No subpackage needed.","symbol":"libsbml","correct":"import libsbml"}],"quickstart":{"code":"import libsbml\nimport sys\n\ndocument = libsbml.SBMLDocument(3, 2)  # SBML Level 3 Version 2\nmodel = document.createModel()\nmodel.setId(\"my_model\")\n\n# Write to file\nwriter = libsbml.SBMLWriter()\nresult = writer.writeSBML(document, \"output.xml\")\nif result != libsbml.LIBSBML_OPERATION_SUCCESS:\n    print(\"Error writing SBML\")\n    sys.exit(1)\n\n# Read back\nreader = libsbml.SBMLReader()\ndocument2 = reader.readSBML(\"output.xml\")\nif document2.getNumErrors() > 0:\n    print(\"Errors encountered:\")\n    document2.printErrors()","lang":"python","description":"Create an SBML Document, write to file, and read it back. Checks for operation success and errors."},"warnings":[{"fix":"Use 'import libsbml'.","message":"The package name on PyPI is 'python-libsbml', but the import is 'libsbml'. Do not use 'import sbml' or 'import libSBML'.","severity":"breaking","affected_versions":"all"},{"fix":"Explicitly pass level and version when creating a new document: libsbml.SBMLDocument(3, 2)","message":"SBMLDocument 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Compare to libsbml.LIBSBML_OPERATION_SUCCESS explicitly: if result != libsbml.LIBSBML_OPERATION_SUCCESS.","message":"Error handling: writeSBML returns an integer status code, not a boolean. Checking 'if result:' may be misleading because LIBSBML_OPERATION_SUCCESS is 0 (falsy).","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":"Install with: pip install python-libsbml. Ensure activating the correct virtual environment.","cause":"Package not installed or wrong Python environment.","error":"ImportError: No module named libsbml"},{"fix":"Do not assign to the name 'libsbml' after importing. Use a different variable for your document: doc = libsbml.SBMLDocument()","cause":"This can happen if there is a name collision: the variable 'libsbml' is redefined or overshadowed.","error":"AttributeError: module 'libsbml' has no attribute 'SBMLDocument'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}