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

Failed to import datashader (missing dependency on dask_expr?) #1319

Closed
1 task
peterroelants opened this issue Mar 13, 2024 · 7 comments
Closed
1 task

Failed to import datashader (missing dependency on dask_expr?) #1319

peterroelants opened this issue Mar 13, 2024 · 7 comments

Comments

@peterroelants
Copy link
Contributor

Thanks for contacting us! Please read and follow these instructions carefully, then delete this introductory text to keep your issue easy to read. Note that the issue tracker is NOT the place for usage questions and technical assistance; post those at Discourse instead. Issues without the required information below may be closed immediately.

ALL software version info

  • python=3.11.8
  • datashader=0.16.0
  • dask-core=2024.3.0

Description of expected behavior and the observed behavior

import datashader leads to ValueError: Must install dask-expr to activate query planning.

❯ python
Python 3.11.8 | packaged by conda-forge | (main, Feb 16 2024, 20:53:32) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>> import datashader
Traceback (most recent call last):
  File "/home/peter/mambaforge/envs/lcms_polymer_env/lib/python3.11/site-packages/dask/dataframe/__init__.py", line 22, in _dask_expr_enabled
    import dask_expr  # noqa: F401
    ^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named 'dask_expr'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/peter/mambaforge/envs/lcms_polymer_env/lib/python3.11/site-packages/datashader/__init__.py", line 9, in <module>
    from .core import Canvas                                 # noqa (API import)
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/peter/mambaforge/envs/lcms_polymer_env/lib/python3.11/site-packages/datashader/core.py", line 9, in <module>
    import dask.dataframe as dd
  File "/home/peter/mambaforge/envs/lcms_polymer_env/lib/python3.11/site-packages/dask/dataframe/__init__.py", line 87, in <module>
    if _dask_expr_enabled():
       ^^^^^^^^^^^^^^^^^^^^
  File "/home/peter/mambaforge/envs/lcms_polymer_env/lib/python3.11/site-packages/dask/dataframe/__init__.py", line 24, in _dask_expr_enabled
    raise ValueError("Must install dask-expr to activate query planning.")
ValueError: Must install dask-expr to activate query planning.

Complete, minimal, self-contained example code that reproduces the issue

import datashader
  • I may be interested in making a pull request to address this
@hoxbro
Copy link
Member

hoxbro commented Mar 13, 2024

Dask recently added this as a dependency (yesterday). See here. You can either install the package or run the following command dask config set dataframe.query-planning false.

I'm not currently sure what we will do in datashader.

@philippjfr
Copy link
Member

This seems like an issue on the dask side tbh. If dask.dataframe depends on dask_expr it then it should depend on it.

@hoxbro
Copy link
Member

hoxbro commented Mar 13, 2024

He is using dask-core. Dask will install dask_expr ref

@raphaelquast
Copy link

Hey, since I just ran into the same issue...
It's true that conda install -c conda-forge dask installs dask_expr as well, but pip install dask does not !
For pip you have to explicitly specify pip install dask[dataframe] (see here)

As I see it, this would mean that pip install datashader is broken but conda install -c conda-forge datashader is not.

@hoxbro
Copy link
Member

hoxbro commented Mar 19, 2024

Does this still happen with 2024.3.1? Because of dask/dask#11003, this should now only give a warning and not an exception.

@weiji14
Copy link

weiji14 commented Apr 12, 2024

Still hitting this with dask=2024.4.1. The ValueError has become an ImportError now after dask/dask#11007:

>>> import datashader
/home/user/mambaforge/envs/dev/lib/python3.11/site-packages/dask/dataframe/__init__.py:31: FutureWarning: 
Dask dataframe query planning is disabled because dask-expr is not installed.

You can install it with `pip install dask[dataframe]` or `conda install dask`.
This will raise in a future version.

  warnings.warn(msg, FutureWarning)
Traceback (most recent call last):
  File "/home/user/mambaforge/envs/dev/lib/python3.11/site-packages/dask/dataframe/__init__.py", line 97, in <module>
    import dask_expr as dd
ModuleNotFoundError: No module named 'dask_expr'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/mambaforge/envs/dev/lib/python3.11/site-packages/datashader/__init__.py", line 9, in <module>
    from .core import Canvas                                 # noqa (API import)
    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/mambaforge/envs/dev/lib/python3.11/site-packages/datashader/core.py", line 9, in <module>
    import dask.dataframe as dd
  File "/home/user/mambaforge/envs/dev/lib/python3.11/site-packages/dask/dataframe/__init__.py", line 110, in <module>
    raise ImportError(msg) from e
ImportError: Dask dataframe requirements are not installed.

Please either conda or pip install as follows:

  conda install dask                     # either conda install
  python -m pip install "dask[dataframe]" --upgrade  # or python -m pip install

weiji14 added a commit to weiji14/zen3geo that referenced this issue Apr 12, 2024
The latest dask=2024.4.1 version installed via readthedocs has a bug with `import datashader` raising `ModuleNotFoundError: No module named 'dask_expr'`. Xref holoviz/datashader#1319
weiji14 added a commit to weiji14/zen3geo that referenced this issue Apr 12, 2024
* ✏️ Edit URL to Mount Talakmau landslide shapefile

Old CERN link seems to be unavailable. New link from https://unosat.org/products/3064 points to https://unosat.org/static/unosat_filesystem/3064/LS20220308IDN_SHP.zip instead.

* 💥 Change vector segmentation mask tutorial to Northern Kelantan

The link to the 20191215 Johor flood water shapefile is no longer available, so switching to 20170104 flood shapefile over the Narathiwat Province in Thailand and Northern Kelantan State in Malaysia. Using an internet archive link this time instead of the UNOSAT link, not only to future-proof against future link rot, but also because the server hosting https://unosat.org/static/unosat_filesystem/2460/FL20170106THA_SHP.zip does not support range requests. Increased chip size from 128x128 to 512x512 to reduce number of batches.

* ✅ Update bbox coords in test_pystac_client_item_search

Minor changes to the bounding box coordinates of the returned STAC item.

* 🚨 Bump GitHub Actions workflows to fix deprecations

Updated actions/checkout and actions/setup-python to silence deprecated warning on Node.js 16 (see https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/).

* 📌 Pin to Python 3.11.8 to avoid dask.dataframe TypeError

Xref dask/dask#11038

* 🐛 Replace UNOSAT link with Wayback Machine permalink

The UNOSAT link doesn't support range requests, resulting in a `DataSourceError: Range downloading not supported by this server!` error. Using the Internet Archive's permalink instead.

* 📌 Temporarily pin dask to <2024.3.0 on readthedocs build

The latest dask=2024.4.1 version installed via readthedocs has a bug with `import datashader` raising `ModuleNotFoundError: No module named 'dask_expr'`. Xref holoviz/datashader#1319

* 📌 Pin to dask=2024.2.1

The less than sign at c24338a didn't work on the readthedocs build.
@hoxbro
Copy link
Member

hoxbro commented Apr 12, 2024

This will be fixed in the next dask release. See dask/dask#11048.

@hoxbro hoxbro closed this as completed May 1, 2024
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

5 participants