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 dask_image.imread fails with scipy.__version__=1.14.1 #388

Open
habi opened this issue Oct 15, 2024 · 6 comments
Open

import dask_image.imread fails with scipy.__version__=1.14.1 #388

habi opened this issue Oct 15, 2024 · 6 comments

Comments

@habi
Copy link

habi commented Oct 15, 2024

I'm working in a new conda environment, with the following environment.yaml file (mine contains more, but this is boiled down to nearly the minimum).

name: newenvironment
channels:
  - conda-forge
dependencies:
  - scipy
  - dask-image

In 'old' notebooks I was able to import dask-image with the call below

import dask_image.imread

(I know, this is probably not the way to do it, but it used to work for a long time :)

Now this fails with

AttributeError: `np.round_` was removed in the NumPy 2.0 release. Use `np.round` instead.

Environment:

  • Dask version: 2023.3.0
  • scipy version: 1.14.1
  • Python version: 3.13.0
  • Operating System: Linux Mint 21.3 Virginia
  • Install method (conda, pip, source): conda 24.7.1
@habi
Copy link
Author

habi commented Oct 15, 2024

from dask.distributed import Client
client = Client()

also does not work, with AttributeError: module 'numpy' has no attribute 'bool8'. Did you mean: 'bool'?

@habi habi changed the title import dask_image.imread fails with numpy.__version__=2.1.2 import dask_image.imread fails with scipy.__version__=1.14.1 Oct 15, 2024
@m-albert
Copy link
Collaborator

Hi @habi, thanks for reporting the issue here.

Unfortunately, I can't reproduce the error using the provided environment file.

AttributeError: np.round_ was removed in the NumPy 2.0 release. Use np.round instead.
AttributeError: module 'numpy' has no attribute 'bool8'. Did you mean: 'bool'?

These two error messages hint towards some package in your environment (which dask-image depends on) not being compatible with numpy >= 2.

For debugging it, it'd be useful to have

  • a larger part of the error traceback you get (for seeing which package contains the np.round_)
  • the full environment.yml
  • the output of pip list.

@habi
Copy link
Author

habi commented Oct 17, 2024

a larger part of the error traceback you get (for seeing which package contains the np.round_)

This is the full traceback:

(newenvironment) [habi@anaklin25|dask-issue]:python
Python 3.13.0 | packaged by conda-forge | (main, Oct  8 2024, 20:04:32) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dask_image.imread
Traceback (most recent call last):
  File "<python-input-0>", line 1, in <module>
    import dask_image.imread
  File "/home/habi/miniconda3/envs/newenvironment/lib/python3.13/site-packages/dask_image/imread/__init__.py", line 6, in <module>
    import dask.array as da
  File "/home/habi/miniconda3/envs/newenvironment/lib/python3.13/site-packages/dask/array/__init__.py", line 2, in <module>
    from dask.array import backends, fft, lib, linalg, ma, overlap, random
  File "/home/habi/miniconda3/envs/newenvironment/lib/python3.13/site-packages/dask/array/ma.py", line 8, in <module>
    from dask.array.routines import _average
  File "/home/habi/miniconda3/envs/newenvironment/lib/python3.13/site-packages/dask/array/routines.py", line 1569, in <module>
    @implements(np.round, np.round_)
                          ^^^^^^^^^
  File "/home/habi/miniconda3/envs/newenvironment/lib/python3.13/site-packages/numpy/__init__.py", line 400, in __getattr__
    raise AttributeError(
    ...<3 lines>...
    )
AttributeError: `np.round_` was removed in the NumPy 2.0 release. Use `np.round` instead.
>>> 

(I saw the problem in a Jupyter notebook, but the error also pops up in Python proper)

the full environment.yml

(newenvironment) [habi@anaklin25|dask-issue]:cat environment.yaml 
name: newenvironment
channels:
  - conda-forge
dependencies:
  - scipy
  - dask-image
(newenvironment) [habi@anaklin25|dask-issue]:

the output of pip list

(newenvironment) [habi@anaklin25|dask-issue]:pip list
Package           Version
----------------- ---------
bokeh             2.4.3
Brotli            1.1.0
cffi              1.17.1
click             8.1.7
cloudpickle       3.1.0
cytoolz           1.0.0
dask              2023.3.0
dask-image        0.0.0
distributed       2023.3.0
fsspec            2024.9.0
h2                4.1.0
hpack             4.0.0
hyperframe        6.0.1
imagecodecs       2024.6.1
imageio           2.36.0
Jinja2            3.1.4
locket            1.0.0
lz4               4.3.3
MarkupSafe        3.0.1
msgpack           1.1.0
numpy             2.1.2
packaging         24.1
pandas            2.2.3
partd             1.4.2
pillow            11.0.0
PIMS              0.7
pip               24.2
psutil            6.0.0
pycparser         2.22
PySocks           1.7.1
python-dateutil   2.9.0
pytz              2024.1
PyYAML            6.0.2
scipy             1.14.1
six               1.16.0
slicerator        1.1.0
sortedcontainers  2.4.0
tblib             3.0.0
tifffile          2024.9.20
toolz             1.0.0
tornado           6.4.1
typing_extensions 4.12.2
tzdata            2024.2
urllib3           2.2.3
zict              3.0.0
zstandard         0.23.0

@jakirkham
Copy link
Member

Can you please update dask? Looks like it and associated packages are coming from 2023. Expect those are not compatible with NumPy 2. Would update to something much more recent

@habi
Copy link
Author

habi commented Oct 18, 2024

That (obviously) fixed the issue.
In this case I seem to misunderstand conda environments, as I expected them to be self-contained.
E.g. when I have dask-image in it, this also "pulls" a recent version of dask.

(I don't understand why this environment file installs dask=2023.3.0, as the machine I'm installing this on physically did not exist prior to July 2024 :) )

@m-albert
Copy link
Collaborator

Great that at least you have a working environment again :)

However what's weird is that dask_image is listed with version 0.0.0 in pip list. I wonder whether there's a problem with the conda feedstock, e.g. related to this.

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

3 participants