EOmaps icon indicating copy to clipboard operation
EOmaps copied to clipboard

datashader library could not be imported

Open konstantinfalkner opened this issue 1 year ago • 1 comments

While running a script with >90 million datapoints following error occured, even tough i installed the datashader module explicitly during the installation of eomaps:

`AssertionError: EOmaps: Missing dependency: 'datashader' 
please install (conda install -c conda-forge datashader) to use 'shade_raster'

Output from spyder call 'get_namespace_view':
EOmaps-Warning: you attempt to plot a large dataset(90280000 datapoints) but the 'datashader' library could not be imported!
The plot might take long to finish!... defaulting to 'ellipses' as plot-shape.`

A Check with conda list showed that it truly is installed:
datashader 0.14.1 pyh6c4a22f_1 conda-forge

Trying an import in the beginning of my script (import datashader as ds) escalates in:

Traceback (most recent call last):

  File "C:\Users\KFalkner\AppData\Local\Temp\ipykernel_6124\3866946782.py", line 1, in <cell line: 1>
    import datashader as ds

  File "C:\Users\KFalkner\Anaconda3\envs\eomaps\lib\site-packages\datashader\__init__.py", line 8, in <module>
    from .core import Canvas                                 # noqa (API import)

  File "C:\Users\KFalkner\Anaconda3\envs\eomaps\lib\site-packages\datashader\core.py", line 13, in <module>
    from .utils import Dispatcher, ngjit, calc_res, calc_bbox, orient_array, \

  File "C:\Users\KFalkner\Anaconda3\envs\eomaps\lib\site-packages\datashader\utils.py", line 8, in <module>
    import numba as nb

  File "C:\Users\KFalkner\Anaconda3\envs\eomaps\lib\site-packages\numba\__init__.py", line 200, in <module>
    _ensure_critical_deps()

  File "C:\Users\KFalkner\Anaconda3\envs\eomaps\lib\site-packages\numba\__init__.py", line 140, in _ensure_critical_deps
    raise ImportError("Numba needs NumPy 1.21 or less")

ImportError: Numba needs NumPy 1.21 or less

This are the versions installed:

numba                     0.55.0          py310h4ed8f06_0
numpy                     1.23.1          py310h8a5b91a_0    conda-forge

I have very little knowledge about modules/packages, but somehow it seems that when installing eomaps a newer (or the newest?) version of numpy is used, which is not compatible with numba yet.

Solution:

I downgraded numpy and everything works fine now: pip install numpy==1.21.6

I had the same issue on 2 Computers so i guess this could be a common problem why i wanted to let you know.

konstantinfalkner avatar Aug 10 '22 11:08 konstantinfalkner

Hey, thanks for pointing this out! (and sorry for the late response... I was on holiday 🏕️)

From your issue I guess you've installed EOmaps via pip into an environment where numpy as already installed... right? (a package manager like conda or mamba would detect the version conflict and downgrade the packages accordingly)

In EOmaps, optional libraries such as datashader are only imported "on demand" and ImportErrors are catched to tell the user why the new dependencies are reqired... I can try to make the error message more descriptive (e.g. by also reporting the original traceback) since for dependency conflicts such as this one the current message is a bit vague...

raphaelquast avatar Sep 05 '22 07:09 raphaelquast

Hey, sorry for the extremely late response, i lost track of it since it's working perfectly now.

But no, I installed with conda/mamba just as in the "Getting started - set up a python environment" section in the docs, and not pip. The only difference is that I'm using anaconda and not miniconda, maybe that is the turning point.

konstantinfalkner avatar Oct 20 '22 08:10 konstantinfalkner

Hey, that's good news, thanks for reporting back!

... and yes, using anaconda could definitely be the cause of the problem since anaconda pre-installs a lot of packages (including numpy) and if you then install EOmaps into the base-environment using pip, this numba version-conflict might occur because pip will most probably not resolve such a version-conflict.

Since everything is working as expected for you and the recommended way of installing EOmaps is with mamba (or conda), I guess this issue can be closed ?

raphaelquast avatar Oct 20 '22 09:10 raphaelquast