Summary
The atomizer crashes immediately on Python 3.12+ because analyzeSBML.py imports the imp module, which was removed from the Python standard library in Python 3.12 (PEP 594, Python 3.12 changelog).
Environment
- Python: 3.12.12 (also affects 3.13+)
- PyBioNetGen: 0.7.9 (installed via
uv pip install bionetgen)
- setuptools: 69.5.1 (needed for
pkg_resources, which is also used by bionetgen/main.py)
- python-libsbml: 5.21.0
- OS: macOS Sonoma (arm64)
Steps to Reproduce
pip install bionetgen
bionetgen atomize -i model.xml -o output/
Error
Traceback (most recent call last):
File ".../bin/bionetgen", line 10, in <module>
sys.exit(main())
File ".../bionetgen/main.py", line 631, in main
app.run()
File ".../cement/core/foundation.py", line 956, in run
return_val = self.controller._dispatch()
File ".../cement/ext/ext_argparse.py", line 835, in _dispatch
return func()
File ".../bionetgen/main.py", line 555, in atomize
runAtomizeTool(self.app)
File ".../bionetgen/core/main.py", line 95, in runAtomizeTool
from bionetgen.atomizer import AtomizeTool
File ".../bionetgen/atomizer/__init__.py", line 1, in <module>
from .atomizeTool import AtomizeTool
File ".../bionetgen/atomizer/atomizeTool.py", line 1, in <module>
import bionetgen.atomizer.libsbml2bngl as ls2b
File ".../bionetgen/atomizer/libsbml2bngl.py", line 15, in <module>
import bionetgen.atomizer.atomizer.moleculeCreation as mc
File ".../bionetgen/atomizer/atomizer/moleculeCreation.py", line 15, in <module>
from . import analyzeSBML
File ".../bionetgen/atomizer/atomizer/analyzeSBML.py", line 9, in <module>
import imp
ModuleNotFoundError: No module named 'imp'
Root Cause
In atomizer/atomizer/analyzeSBML.py, line 9:
The imp module was deprecated in Python 3.4 and fully removed in Python 3.12 per PEP 594. The only usage appears to be imp.reload(), which should be replaced with importlib.reload().
Secondary Issue
There is also a related (but separate) issue: bionetgen/main.py line 21 uses:
from pkg_resources import packaging
The pkg_resources module requires setuptools to be installed, which is no longer bundled by default in Python 3.12+ virtual environments created by uv or with python -m venv. This is a separate bug from the imp issue but compounds the problem — even after manually installing setuptools<70 to get past pkg_resources, the atomizer still fails on the imp import.
Suggested Fix
In atomizer/atomizer/analyzeSBML.py, replace:
with:
And replace any usage of imp.reload(module) with:
For the pkg_resources issue in bionetgen/main.py, consider replacing:
from pkg_resources import packaging
with:
from importlib.metadata import version
or using packaging directly (pip install packaging).
Impact
This blocks all SBML → BNGL conversion on Python 3.12+, which is the current stable Python release series. Users must downgrade to Python 3.11 to use the atomizer, which is increasingly impractical as the ecosystem moves forward.
Summary
The atomizer crashes immediately on Python 3.12+ because
analyzeSBML.pyimports theimpmodule, which was removed from the Python standard library in Python 3.12 (PEP 594, Python 3.12 changelog).Environment
uv pip install bionetgen)pkg_resources, which is also used bybionetgen/main.py)Steps to Reproduce
Error
Root Cause
In
atomizer/atomizer/analyzeSBML.py, line 9:The
impmodule was deprecated in Python 3.4 and fully removed in Python 3.12 per PEP 594. The only usage appears to beimp.reload(), which should be replaced withimportlib.reload().Secondary Issue
There is also a related (but separate) issue:
bionetgen/main.pyline 21 uses:The
pkg_resourcesmodule requiressetuptoolsto be installed, which is no longer bundled by default in Python 3.12+ virtual environments created byuvor withpython -m venv. This is a separate bug from theimpissue but compounds the problem — even after manually installingsetuptools<70to get pastpkg_resources, the atomizer still fails on theimpimport.Suggested Fix
In
atomizer/atomizer/analyzeSBML.py, replace:with:
And replace any usage of
imp.reload(module)with:For the
pkg_resourcesissue inbionetgen/main.py, consider replacing:with:
or using
packagingdirectly (pip install packaging).Impact
This blocks all SBML → BNGL conversion on Python 3.12+, which is the current stable Python release series. Users must downgrade to Python 3.11 to use the atomizer, which is increasingly impractical as the ecosystem moves forward.