e-koch / FilFinder

Detection of filamentary structure in molecular clouds
http://fil-finder.readthedocs.io/en/latest
MIT License
41 stars 21 forks source link

ImportError: cannot import name 'update_default_config' from 'astropy.config.configuration' #82

Open Ekanshh opened 5 months ago

Ekanshh commented 5 months ago

Description: Encountering an ImportError when attempting to run a script or code relying on the fil_finder module. The issue arises due to the inability to import the 'update_default_config' function from 'astropy.config.configuration'.

Minimal code to reproduce:

from fil_finder import FilFinder2D
import astropy.units as u

Error message:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[2], line 1
----> 1 from fil_finder import FilFinder2D
      2 import astropy.units as u

File ~/anaconda3/envs/<env_name>/lib/python3.10/site-packages/fil_finder/__init__.py:3
      1 # Licensed under an MIT open source license - see LICENSE
----> 3 from ._astropy_init import *
      5 if not _ASTROPY_SETUP_:
      6     from .filfind_class import fil_finder_2D

File ~/anaconda3/envs/<env_name>/lib/python3.10/site-packages/fil_finder/_astropy_init.py:21
     19 import os
     20 from warnings import warn
---> 21 from astropy.config.configuration import (
     22     update_default_config,
     23     ConfigurationDefaultMissingError,
     24     ConfigurationDefaultMissingWarning)
     26 # Create the test function for self test
     27 from astropy.tests.runner import TestRunner

ImportError: cannot import name 'update_default_config' from 'astropy.config.configuration' (/home/<username>/anaconda3/envs/<env_name>/lib/python3.10/site-packages/astropy/config/configuration.py)

Installation Method:

pip install fil_finder

Additional Information:

Package Version
astropy 6.0.1
astropy_healpix 1.0.3
astropy-iers-data 0.2024.4.8.0.32.4
fil-finder 1.7.2

Proposed Solution:

Given the deprecation of update_default_config and ConfigurationMissingWarning in the astropy.config module, as indicated in the official changelog of Astropy in astropy>=v6.0.0 , I propose to remove the import statement for update_default_config from the _astropy_init.py file within the fil_finder package directory. This has worked for me :)

Before:

from astropy.config.configuration import (
    update_default_config,
    ConfigurationDefaultMissingError,
    ConfigurationDefaultMissingWarning)

After:

from astropy.config.configuration import (
    ConfigurationDefaultMissingError,
    ConfigurationDefaultMissingWarning)

If deemed appropriate, I'm willing to create a pull request (PR) to implement this solution. Let me know your thoughts.

e-koch commented 5 months ago

Thanks for reporting the issue, @Ekanshh! I've started updating the CI tests and will add this to that PR.