Skip to content

Python 3.12: ModuleNotFoundError: No module named 'imp'

Summary

When running the unit tests with Python 3.12 there's a ModuleNotFoundError

_______________________________________________ ERROR collecting unittests/test_concrete_property.py _________________________________________________
ImportError while importing test module '/home/joscha/caosdb/src/caosdb-pylib/unittests/test_concrete_property.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
../../env/lib64/python3.12/site-packages/_pytest/python.py:538: in importtestmodule
    mod = import_path(path, mode=importmode, root=config.rootpath)
../../env/lib64/python3.12/site-packages/_pytest/pathlib.py:566: in import_path
    importlib.import_module(module_name)
/usr/lib64/python3.12/importlib/__init__.py:90: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1387: in _gcd_import
    ???
<frozen importlib._bootstrap>:1360: in _find_and_load
    ???
<frozen importlib._bootstrap>:1331: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:935: in _load_unlocked
    ???
../../env/lib64/python3.12/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
unittests/test_concrete_property.py:31: in <module>
    from nose.tools import assert_equal as eq
../../env/lib64/python3.12/site-packages/nose/__init__.py:1: in <module>
    from nose.core import collector, main, run, run_exit, runmodule
../../env/lib64/python3.12/site-packages/nose/core.py:12: in <module>
    from nose.loader import defaultTestLoader
../../env/lib64/python3.12/site-packages/nose/loader.py:21: in <module>
    from nose.importer import Importer, add_path, remove_path
../../env/lib64/python3.12/site-packages/nose/importer.py:12: in <module>
    from imp import find_module, load_module, acquire_lock, release_lock
E   ModuleNotFoundError: No module named 'imp'

Expected Behavior

Tests should not crash

Actual Behavior

Tests fail immediately. Importing linkahead seems to work, and manually doing some queries works as well.

Steps to Reproduce the Problem

  1. Clone repository and setup
  2. Run tox or pytest

Specifications

  • Version:
  • Platform: Fedora 38, Python 3.12.2
Environment
asttokens==2.4.1
attrs==23.2.0
cachetools==5.3.3
certifi==2024.2.2
chardet==5.2.0
charset-normalizer==3.3.2
colorama==0.4.6
coverage==7.4.3
decorator==5.1.1
distlib==0.3.8
executing==2.0.1
filelock==3.13.1
future==1.0.0
idna==3.6
iniconfig==2.0.0
ipython==8.22.2
jedi==0.19.1
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
linkahead==0.14.0
lxml==5.1.0
matplotlib-inline==0.1.6
nose==1.3.7
packaging==23.2
parso==0.8.3
pexpect==4.9.0
platformdirs==4.2.0
pluggy==1.4.0
prompt-toolkit==3.0.43
ptyprocess==0.7.0
pure-eval==0.2.2
Pygments==2.17.2
pyproject-api==1.6.1
PySocks==1.7.1
pytest==8.0.2
pytest-cov==4.1.0
python-dateutil==2.9.0.post0
PyYAML==6.0.1
referencing==0.33.0
requests==2.31.0
rpds-py==0.18.0
setuptools==69.1.1
six==1.16.0
stack-data==0.6.3
tox==4.14.1
traitlets==5.14.1
urllib3==2.2.1
virtualenv==20.25.1
wcwidth==0.2.13

Possible fixes

Probably an issue with nose that is not compatible with Python 3.12.

Edited by Joscha Schmiedt
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information