Skip to content

sphn-mocker incompatible with Python 3.12

When running sphn-mocker in an environment with Python 3.12, I run into the following error:

File "", line 1, in File "/opt/homebrew/Cellar/python@3.12/3.12.2/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/init.py",
line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) 
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", 
line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, 
in _load_unlocked File "", line 995, in exec_module File "", line 488, in 
_call_with_frames_removed File "/Users/unni0000/GIT/sphn-mocker-test/sphn_mocker/cli.py", line 
21, in from .schema import Schema File "/Users/unni0000/GIT/sphn-mocker-
test/sphn_mocker/schema.py", line 11, in from .interfaces import generate_mapping, 
write_mock_data_to_ttl File "/Users/unni0000/GIT/sphn-mocker-test/sphn_mocker/interfaces.py", 
line 8, in from distutils.sysconfig import get_python_lib ModuleNotFoundError: No module named 
'distutils'

This is due to distutils being removed in Python 3.12. See https://stackoverflow.com/questions/69919970/no-module-named-distutils-but-distutils-installed/76691103#76691103

Short term: It would be good to update the README to communicate that sphn-mocker is compatible with Python 3.11 and below.

Long term: Update installation guide to account for the additional installation of setuptools

Edited by Deepak Unni