Skip to content

Waf configuration issue with Python 3.12 - no module named 'imp' #402

@alexsobotka

Description

@alexsobotka

I'm trying to update my CLASS and Montepython installations to Python 3.12. Running into trouble when attempting to configure Planck likelihoods using waf:

[asobotka@longleaf-login2 plc-3.01]$ /nas/longleaf/rhel9/apps/python/3.12.4/bin/python3 waf configure --install_all_deps --cfitsio_prefix=/nas/longleaf/home/asobotka/cfitsio-4.0.0

Traceback (most recent call last):
  File "/nas/longleaf/home/asobotka/planck/code/plc_3.0/plc-3.01/waf", line 164, in <module>
    from waflib import Scripting
  File "/nas/longleaf/home/asobotka/planck/code/plc_3.0/plc-3.01/.waf3-2.0.17-c5414c9b1eca70e1add79159e16494fe/waflib/Scripting.py", line 7, in <module>
    from waflib import Utils,Configure,Logs,Options,ConfigSet,Context,Errors,Build,Node
  File "/nas/longleaf/home/asobotka/planck/code/plc_3.0/plc-3.01/.waf3-2.0.17-c5414c9b1eca70e1add79159e16494fe/waflib/Configure.py", line 6, in <module>
    from waflib import ConfigSet,Utils,Options,Logs,Context,Build,Errors
  File "/nas/longleaf/home/asobotka/planck/code/plc_3.0/plc-3.01/.waf3-2.0.17-c5414c9b1eca70e1add79159e16494fe/waflib/Options.py", line 6, in <module>
    from waflib import Logs,Utils,Context,Errors
  File "/nas/longleaf/home/asobotka/planck/code/plc_3.0/plc-3.01/.waf3-2.0.17-c5414c9b1eca70e1add79159e16494fe/waflib/Context.py", line 5, in <module>
    import os,re,imp,sys
ModuleNotFoundError: No module named 'imp'

According to Python 3.11 documentation, the imp package is removed in Python 3.12:

Deprecated since version 3.4, will be removed in version 3.12: The imp module is deprecated in favor of importlib.
imp — Access the import internals — Python 3.11.8 documentation

One could try to use a python version older than 3.12. Unfortunately, my cluster just updated to RHEL 9 and Python 3.12 is the only available version at this time.

Would it be a bad idea to manually edit the waflib/Context.py file to use importlib instead of imp? Does anyone have a possible solution?

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions