Skip to content

fix error with DistrubutionNotFound and switch to PackageNotFoundError#146

Open
ASKabalan wants to merge 2 commits intoDifferentiableUniverseInitiative:masterfrom
ASKabalan:fix-import-error
Open

fix error with DistrubutionNotFound and switch to PackageNotFoundError#146
ASKabalan wants to merge 2 commits intoDifferentiableUniverseInitiative:masterfrom
ASKabalan:fix-import-error

Conversation

@ASKabalan
Copy link
Member

This pull request updates how the package version is retrieved in jax_cosmo/__init__.py to use the modern importlib.metadata module instead of the deprecated pkg_resources. This change improves compatibility with newer Python versions and avoids unnecessary dependencies.

  • Modernized version retrieval:
    • Replaced pkg_resources.get_distribution and DistributionNotFound with importlib.metadata.version and PackageNotFoundError in jax_cosmo/__init__.py.

This warning is now an error on python 3.10

Traceback:
/opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
test_spherical_painting_methods.py:25: in <module>
    import jax_cosmo as jc
/opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/site-packages/jax_cosmo/__init__.py:2: in <module>
    from pkg_resources import DistributionNotFound
E   ModuleNotFoundError: No module named 'pkg_resources'

Which blocs JaxPM CI => https://github.com/DifferentiableUniverseInitiative/JaxPM/actions/runs/22356291638/job/64696767811?pr=54

@ASKabalan
Copy link
Member Author

Please merge before #145

This was referenced Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant