Skip to content
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

Import error from tlz when cytoolz not installed #597

Open
jrbourbeau opened this issue Dec 19, 2024 · 2 comments
Open

Import error from tlz when cytoolz not installed #597

jrbourbeau opened this issue Dec 19, 2024 · 2 comments

Comments

@jrbourbeau
Copy link
Member

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

@eriknw
Copy link
Member

eriknw commented Dec 19, 2024

Oh my! I'll take a look. I thought tests would catch this? This code hasn't been updated in a while. I think there's still 2.7-specific code that can be removed.

@jrbourbeau
Copy link
Member Author

I'm actually now unsure if this is just me or not. I asked some coworkers to try and reproduce, but they're not able to. Also, nobody has opened an issue in dask for this, which surprised me. I tried again after clearing my local conda cache, but am still seeing the same error... 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants