Skip to content

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

Description

@drewyangdev

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

  1. added
    bugIndicates an unexpected problem or unintended behavior
    triageIndicates issues, pull requests, or discussions need to be reviewed for the first time
    on Mar 21, 2025
  2. removed
    triageIndicates issues, pull requests, or discussions need to be reviewed for the first time
    on Mar 21, 2025
  3. added
    triageIndicates issues, pull requests, or discussions need to be reviewed for the first time
    on Mar 21, 2025
  4. removed
    triageIndicates issues, pull requests, or discussions need to be reviewed for the first time
    on Mar 21, 2025
  5. changed the title [-]Bug: py3.13 | ModuleNotFoundError: No module named 'pkg_resources'[/-] [+]Bug: conda-forge Python 3.13 | ModuleNotFoundError: No module named 'pkg_resources'[/+] on Mar 21, 2025
  6. self-assigned this
    on Mar 21, 2025
  7. linked a pull request that will close this issueFix #1218 #1219on Mar 21, 2025
  8. added a commit that references this issue on Mar 24, 2025
  9. timonmerk commented on Apr 2, 2025

    @timonmerk

    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'

  10. drewyangdev commented on Apr 2, 2025

    @drewyangdev
    ContributorAuthor

    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?

  11. timonmerk commented on Apr 2, 2025

    @timonmerk

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

  12. drewyangdev commented on Apr 2, 2025

    @drewyangdev
    ContributorAuthor

    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

Metadata

Metadata

Labels

bugIndicates an unexpected problem or unintended behavior

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions