Module 'numpy' has no attribute 'warnings'

Very new to Holoviz.
I am following this Datashader example, using my own dataset. I get the following error when building the doc. (doc = renderer.server_doc(hvobj))

WARNING:param.dynamic_operation: Callable raised "AttributeError("module 'numpy' has no attribute 'warnings'")"

Then I downgraded numpy to 1.23.1 as it was advised in the Stackoverflow. It didn’t help either.

I’ve used pip to install packages in a venv using following requirements.txt:

# Dependencies for holoenv2

## General
jupyterlab
fastparquet
xarray

## Holoviz
panel
hvplot
holoviews
datashader
param

Because of my company’s policy, I can’t use conda and need to figure out how to get the package dependencies right in pip. What am I missing?

Using the set up doc, I was able to put together the right combination of dependencies. Now, the doc shows.

Dependencies for holoenv2

General

fastparquet
xarray

Holoviz

panel
hvplot
holoviews
datashader
param >=1.9.2
bokeh >=3.1.1,<3.2.0
param >=1.12.0
pyviz_comms >=0.7.4

Bokeh dependency, but pyodide 23.0.0 does not always pick it up

xyzservices >=2021.09.1
markdown
markdown-it-py
linkify-it-py
mdit-py-plugins
requests
tqdm >=4.48.0
bleach
typing_extensions
pandas >=1.2
jupyterlab
jupyter_bokeh >=3.0.7
holoviews >=1.16.0
matplotlib
pillow
plotly
lxml
numpy <1.24

The problem you were seeing was definitely related to numpy 1.24. This will be fixed in the next Datashader release, expected to be released next week.

The example is pretty old, this is a more modern way to do it and then launch it with panel serve

import dask.dataframe as dd
import holoviews as hv
import numpy as np
import panel as pn
from holoviews import opts
from holoviews.operation.datashader import aggregate

hv.extension("bokeh")

# Set plot and style options
opts.defaults(
    opts.Curve(
        xaxis=None,
        yaxis=None,
        show_grid=False,
        show_frame=False,
        color="orangered",
        framewise=True,
        width=100,
    ),
    opts.Image(
        width=800,
        height=400,
        shared_axes=False,
        logz=True,
        colorbar=True,
        xaxis=None,
        yaxis=None,
        axiswise=True,
        bgcolor="black",
        cmap="fire",
    ),
    opts.HLine(color="white", line_width=1),
    opts.Layout(shared_axes=False),
    opts.VLine(color="white", line_width=1),
)

# Read the parquet file
df = dd.read_parquet("~/Downloads/nyc_taxi_wide.parq", engine="fastparquet").compute()

# Declare points
points = hv.Points(df, kdims=["pickup_x", "pickup_y"], vdims=[])

# Use datashader to rasterize and linked streams for interactivity
agg = aggregate(points, link_inputs=True, x_sampling=0.0001, y_sampling=0.0001)
pointerx = hv.streams.PointerX(x=np.mean(points.range("pickup_x")), source=points)
pointery = hv.streams.PointerY(y=np.mean(points.range("pickup_y")), source=points)
vline = hv.DynamicMap(lambda x: hv.VLine(x), streams=[pointerx])
hline = hv.DynamicMap(lambda y: hv.HLine(y), streams=[pointery])

sampled = hv.util.Dynamic(
    agg,
    operation=lambda obj, x: obj.sample(pickup_x=x),
    streams=[pointerx],
    link_inputs=False,
)

hvobj = (agg * hline * vline) << sampled

pn.panel(hvobj).servable()
1 Like

Thanks for the response and for the modern version of the example. I tried it.

Hi @Hoxbro, can you provide an ETA on the release. One of the projects I work on, cuXfilter(Require Numba 0.57.0+ & NumPy 1.21.0+ by jakirkham · Pull Request #480 · rapidsai/cuxfilter · GitHub) uses datashader, and we are facing issues in docs build due to the same issue.

We have temporarily decided to pin numpy to <1.24 as a solution.

It has been released on PyPi and is in the process on being added to conda-forge.

So soon :slight_smile:

1 Like