Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use importlib_resources instead of pkg_resources. #42

Open
kelle opened this issue Sep 18, 2024 · 1 comment
Open

Use importlib_resources instead of pkg_resources. #42

kelle opened this issue Sep 18, 2024 · 1 comment

Comments

@kelle
Copy link

kelle commented Sep 18, 2024

Getting lots of deprecation warnings in Python 3.11 due to the deprecation of pkg_resources. Please modify code to use importlib_resources instead.

 DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    from pkg_resources import resource_filename

For example:

file = resource_filename('sedkit', 'data/sources.txt')

becomes

file = importlib_resources.files('sedkit')/ 'data/sources.txt'
@pmocz
Copy link

pmocz commented Sep 18, 2024

possible gotcha: May need to use, e.g., str(importlib.resources.files('sedkit')/ 'data/sources.txt') in some cases for a quick fix, since I see this path is sometimes treated and manipulated as a string. importlib_resources.files returns a PosixPath object while resource_filename used to return a string

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

No branches or pull requests

2 participants