Repository navigation
Bug: conda-forge Python 3.13 | ModuleNotFoundError: No module named 'pkg_resources' #1218
Description
Bug Report
Description
While working with conda-forge release, I found the datajoint-feedtest test would fail for me on python 3.13
python -c 'import datajoint as dj; assert dj.diagram.diagram_active'
# ModuleNotFoundError: No module named 'pkg_resources'
Reproducibility
Include:
- OS (Linux)
- Python Version 3.13
- DataJoint Version Unreleased 3e39771
- Minimum number of steps to reliably reproduce the issue
which conda
# /home/drewyang/miniconda3/condabin/conda
conda --version
# conda 25.1.1
conda create -n dj313 -c conda-forge python=3.13 # installed from conda-forge instead of the defaults channel 'conda-forge/linux-64::python-3.13.2-hf636f53_101_cp313'
conda activate dj313
# cd <datajoint-python repo>
git checkout 3e3977147aedcef735561427664a4c7a81d3862f # latest master as of 20250320
pip install -e .
python -c 'import datajoint as dj; assert dj.diagram.diagram_active'
- Complete error stack as a result of evaluating the above steps
Traceback (most recent call last):
File "<string>", line 1, in <module>
import datajoint as dj; assert dj.diagram.diagram_active
^^^^^^^^^^^^^^^^^^^^^^
File "/home/drewyang/Documents/DataJoint/datajoint-python/datajoint/__init__.py", line 59, in <module>
from .admin import kill, set_password
File "/home/drewyang/Documents/DataJoint/datajoint-python/datajoint/admin.py", line 7, in <module>
from .connection import conn
File "/home/drewyang/Documents/DataJoint/datajoint-python/datajoint/connection.py", line 19, in <module>
from .plugin import connection_plugins
File "/home/drewyang/Documents/DataJoint/datajoint-python/datajoint/plugin.py", line 4, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
Expected Behavior
which conda
# /home/drewyang/miniconda3/condabin/conda
conda --version
# conda 25.1.1
conda create -n dj312 -c conda-forge python=3.12 # installed from conda-forge instead of the defaults channel 'conda-forge/linux-64::python-3.13.2-hf636f53_101_cp313'
conda activate dj312
# cd <datajoint-python repo>
git checkout 3e3977147aedcef735561427664a4c7a81d3862f # latest main as of 20250320
pip install -e .
python -c 'import datajoint as dj; assert dj.diagram.diagram_active'
# No output or error
Additional Research and Context
setuptools isn't a default dependency of Python 3.13 anymore, suggest to add to the pyproject.toml.
However, I also tried the same on Mac, which installed the conda default channel's python 3.13 for osx-64, it does include setuptools, which didn't cause the same issue.
I suggest we explicitly include setuptools in pyproject.yaml as a dependency(not a build dependency, but a package dependency)
Also setuptools.pkg_resources will be deprecated.
Use of pkg_resources is deprecated in favor of importlib.resources, importlib.metadata and their backports (importlib_resources, importlib_metadata). Some useful APIs are also provided by packaging (e.g. requirements and version parsing). Users should refrain from new usage of pkg_resources and should work to port to importlib-based solutions.
Activity
[-]Bug: py3.13 | ModuleNotFoundError: No module named 'pkg_resources'[/-][+]Bug: conda-forge Python 3.13 | ModuleNotFoundError: No module named 'pkg_resources'[/+]Merge branch 'master' into fix-datajoint#1218
Merge pull request #1219 from yambottle/fix-#1218
timonmerk commentedon Apr 2, 2025
I still get the issue installing the package using pip:
drewyangdev commentedon Apr 2, 2025
Can you please show your
pip list? I'd expect you don't have setup tools installed?timonmerk commentedon Apr 2, 2025
You're right @yambottle! That was the issue. Maybe setuptools could be then added to the pyproject.toml
drewyangdev commentedon Apr 2, 2025
Yeah, I made a PR added it already, it's linked to this issue if you look at the activity trace of this issue. It'll be an explicit dependency in the next release, and it's coming soon!