Skip to content

Bug: conda-forge Python 3.13 | ModuleNotFoundError: No module named 'pkg_resources' #1218

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

Closed
drewyangdev opened this issue Mar 21, 2025 · 4 comments · Fixed by #1219
Closed
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@drewyangdev
Copy link
Contributor

drewyangdev commented Mar 21, 2025

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.

@drewyangdev drewyangdev added bug Indicates an unexpected problem or unintended behavior triage Indicates issues, pull requests, or discussions need to be reviewed for the first time labels Mar 21, 2025
@drewyangdev drewyangdev removed the triage Indicates issues, pull requests, or discussions need to be reviewed for the first time label Mar 21, 2025
@github-actions github-actions bot added the triage Indicates issues, pull requests, or discussions need to be reviewed for the first time label Mar 21, 2025
@drewyangdev drewyangdev removed the triage Indicates issues, pull requests, or discussions need to be reviewed for the first time label Mar 21, 2025
@drewyangdev drewyangdev changed the title Bug: py3.13 | ModuleNotFoundError: No module named 'pkg_resources' Bug: conda-forge Python 3.13 | ModuleNotFoundError: No module named 'pkg_resources' Mar 21, 2025
@drewyangdev drewyangdev self-assigned this Mar 21, 2025
@drewyangdev drewyangdev added the in-progress Indicates work in progress label Mar 21, 2025
@drewyangdev drewyangdev linked a pull request Mar 21, 2025 that will close this issue
drewyangdev pushed a commit to drewyangdev/datajoint-python that referenced this issue Mar 24, 2025
@drewyangdev drewyangdev removed the in-progress Indicates work in progress label Mar 25, 2025
@timonmerk
Copy link

I still get the issue installing the package using pip:

In [2]: import datajoint

ModuleNotFoundError Traceback (most recent call last)
Cell In[2], line 1
----> 1 import datajoint

File ~/Documents/datajoint_playground/.venv/lib/python3.12/site-packages/datajoint/init.py:61
59 from .version import version
60 from .settings import config
---> 61 from .connection import conn, Connection
62 from .schemas import Schema
63 from .schemas import VirtualModule, list_schemas

File ~/Documents/datajoint_playground/.venv/lib/python3.12/site-packages/datajoint/connection.py:19
17 from .blob import pack, unpack
18 from .hash import uuid_from_buffer
---> 19 from .plugin import connection_plugins
21 logger = logging.getLogger(name.split(".")[0])
22 query_log_max_length = 300

File ~/Documents/datajoint_playground/.venv/lib/python3.12/site-packages/datajoint/plugin.py:2
1 from .settings import config
----> 2 import pkg_resources
3 from pathlib import Path
4 from cryptography.exceptions import InvalidSignature

ModuleNotFoundError: No module named 'pkg_resources'

@drewyangdev
Copy link
Contributor Author

I still get the issue installing the package using pip:

In [2]: import datajoint

ModuleNotFoundError Traceback (most recent call last)
Cell In[2], line 1
----> 1 import datajoint

File ~/Documents/datajoint_playground/.venv/lib/python3.12/site-packages/datajoint/init.py:61
59 from .version import version
60 from .settings import config
---> 61 from .connection import conn, Connection
62 from .schemas import Schema
63 from .schemas import VirtualModule, list_schemas

File ~/Documents/datajoint_playground/.venv/lib/python3.12/site-packages/datajoint/connection.py:19
17 from .blob import pack, unpack
18 from .hash import uuid_from_buffer
---> 19 from .plugin import connection_plugins
21 logger = logging.getLogger(name.split(".")[0])
22 query_log_max_length = 300

File ~/Documents/datajoint_playground/.venv/lib/python3.12/site-packages/datajoint/plugin.py:2
1 from .settings import config
----> 2 import pkg_resources
3 from pathlib import Path
4 from cryptography.exceptions import InvalidSignature

ModuleNotFoundError: No module named 'pkg_resources'

Can you please show your pip list? I'd expect you don't have setup tools installed?

@timonmerk
Copy link

You're right @yambottle! That was the issue. Maybe setuptools could be then added to the pyproject.toml

@drewyangdev
Copy link
Contributor Author

drewyangdev commented Apr 2, 2025

You're right @yambottle! That was the issue. Maybe setuptools could be then added to the pyproject.toml

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants