INCATools / INCATools/ontology-access-kit

ModuleNotFoundError: No module named 'pkg_resources' caused by class_resolver dependency

Open
#412 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
198
Forks
35
Avg merge
3d 4h
Merged PRs (30d)
1

Description

When running from poetry:

```
✗ runoak --help
Traceback (most recent call last):
File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/bin/runoak", line 2, in
from oaklib.cli import main
File "/Users/cjm/repos/ontology-access-kit/src/oaklib/__init__.py", line 7, in
from oaklib.interfaces import BasicOntologyInterface # noqa:F401
File "/Users/cjm/repos/ontology-access-kit/src/oaklib/interfaces/__init__.py", line 1, in
from oaklib.interfaces.basic_ontology_interface import BasicOntologyInterface
File "/Users/cjm/repos/ontology-access-kit/src/oaklib/interfaces/basic_ontology_interface.py", line 25, in
from oaklib.interfaces.ontology_interface import OntologyInterface
File "/Users/cjm/repos/ontology-access-kit/src/oaklib/interfaces/ontology_interface.py", line 4, in
from oaklib.resource import OntologyResource
File "/Users/cjm/repos/ontology-access-kit/src/oaklib/resource.py", line 5, in
from class_resolver import HintOrType
File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/class_resolver/__init__.py", line 48, in
from .api import (
File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/class_resolver/api.py", line 10, in
from .base import BaseResolver
File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/class_resolver/base.py", line 9, in
from pkg_resources import iter_entry_points
ModuleNotFoundError: No module named 'pkg_resources'
```

can be isolated to:

```
>>> from class_resolver import HintOrType
Traceback (most recent call last):
File "", line 1, in
File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/class_resolver/__init__.py", line 48, in
from .api import (
File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/class_resolver/api.py", line 10, in
from .base import BaseResolver
File "/Users/cjm/Library/Caches/pypoetry/virtualenvs/oaklib-OeQZizwE-py3.9/lib/python3.9/site-packages/class_resolver/base.py", line 9, in
from pkg_resources import iter_entry_points
ModuleNotFoundError: No module named 'pkg_resources'
```

https://stackoverflow.com/questions/7446187/no-module-named-pkg-resources

I am not sure I fully understand. I can't replicate this with a new poetry project with only class_resolver as a dependency. pkg_resources should be part of the standard distribution

https://setuptools.pypa.io/en/latest/pkg_resources.html
says

Attention

Use of pkg_resources is discouraged in favor of [importlib.resources](https://docs.python.org/3/library/importlib.html#module-importlib.resources), [importlib.metadata](https://docs.python.org/3/library/importlib.metadata.html), and their backports ([importlib_resources](https://pypi.org/project/importlib_resources), [importlib_metadata](https://pypi.org/project/importlib_metadata)). Please consider using those libraries instead of pkg_resources.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `runoak --help` and `from class_resolver import HintOrType` in the Poetry environment. Trace the imports through `src/oaklib/resource.py`, `oaklib/interfaces/ontology_interface.py`, and the installed `class_resolver/base.py`; done means the CLI and isolated import no longer fail with `ModuleNotFoundError: pkg_resources`.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.