desihub / speclite

Lightweight utilities for working with spectroscopic data
14 stars 17 forks source link

ModuleNotFoundError: No module named 'imp' #89

Open pentyum opened 1 week ago

pentyum commented 1 week ago

Cannot install speclite on Python 3.12, because Python 3.12 has removed the imp package.

Traceback (most recent call last):
        File "/home/user/desihub/speclite/astropy_helpers/setup.py", line 22, in <module>
          from astropy_helpers.version_helpers import generate_version_py  # noqa
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/user/desihub/speclite/astropy_helpers/astropy_helpers/version_helpers.py", line 34, in <module>
          from .distutils_helpers import is_distutils_display_option
        File "/home/user/desihub/speclite/astropy_helpers/astropy_helpers/distutils_helpers.py", line 18, in <module>
          from .utils import silence
        File "/home/user/desihub/speclite/astropy_helpers/astropy_helpers/utils.py", line 4, in <module>
          import imp
      ModuleNotFoundError: No module named 'imp'
sbailey commented 6 days ago

Thanks for noting this. In python 3.10, import imp reports

DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses

@pentyum would you be willing to make a speclite PR that replaces imp with importlib? I'm not sure if that is a drop-in replacement or requires some syntax changes to how it is used. If you can't do this, ok, we'll put it on our to-do list but there will be some delay before we find time to update this.

Also, side note: I don't recognize your github user name but see you have popped up on several DESI-related repos recently; thanks for those reports and fixes. If you are a DESI collaborator, please message me on the DESI slack so that we have some context about who this is, and establish an alternate non-github communication channel as well. Thanks.

sbailey commented 6 days ago

@pentyum update: now I see on desigal that you already identified that you are not a desi collaborator. Thanks for your interest in DESI data and patience and contributions to our code.

weaverba137 commented 6 days ago

Technical note: the import error is not in speclite itself, but in the deprecated astropy_helpers submodule. The solution is simply to eliminate the submodule entirely and bring speclite up to modern packaging standards, but as previously noted, that could take a while.