datayoga-io/datayoga

Include setuptools as a required dependency in the package's setup.py or pyproject.toml

Closed this issue · 0 comments

Installed datayoga using pip install datayoga finished with no errors.
tryied running datayoga --version got following error:
Traceback (most recent call last):
File "/home/dtrop/my_venv/bin/datayoga", line 5, in
from datayoga.main import main
File "/home/dtrop/my_venv/lib/python3.12/site-packages/datayoga/main.py", line 17, in
from pkg_resources import DistributionNotFound, get_distribution
ModuleNotFoundError: No module named 'pkg_resources'

fixed when installed pip install setuptools
based on this:

This error occurs because the pkg_resources module is missing. This module is typically provided by setuptools, but in newer Python versions (especially Python 3.12), it needs to be installed separately.
Here's how to fix it:
bashCopypip install setuptools
After installing setuptools, try running the datayoga --version command again. It should work now.
For future reference, we should update the package's dependencies to either:

Include setuptools as a required dependency in the package's setup.py or pyproject.toml
Or migrate from pkg_resources to importlib.metadata, which is part of the Python standard library since Python 3.8

Here's how the migration to importlib.metadata would look in main.py:
pythonCopytry:
from importlib.metadata import version, PackageNotFoundError
version = version("datayoga")
except PackageNotFoundError:
version = "unknown"
Would you like me to help you implement either of these solutions?