Skip to content

Import error from tlz when cytoolz not installed #597

@jrbourbeau

Description

@jrbourbeau

Today I created a minimal environment like this

mamba create -n test python=3.12 ipython
mamba activate test
pip install toolz

and then attempt to make this import from tlz: from tlz import groupby, merge and got this error

In [1]: from tlz import groupby, merge
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 from tlz import groupby, merge

File ~/mambaforge/envs/test6/lib/python3.12/site-packages/tlz/_build_tlz.py:55, in TlzLoader.exec_module(self, module)
     54 def exec_module(self, module):
---> 55     toolz_mods = self._load_toolz(module.__name__)
     56     fast_mod = toolz_mods.get('cytoolz') or toolz_mods['toolz']
     57     slow_mod = toolz_mods.get('toolz') or toolz_mods['cytoolz']

File ~/mambaforge/envs/test6/lib/python3.12/site-packages/tlz/_build_tlz.py:29, in TlzLoader._load_toolz(self, fullname)
     27     pass
     28 if not rv:
---> 29     raise ImportError(fullname)
     30 return rv

ImportError: tlz.groupby

If I then install cytoolz, the error goes away. I came across this because from tlz import groupby, merge gets run as part of import dask

cc @eriknw in case you have any idea what's going on here

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions