Get help from the marimo community

Updated 4 weeks ago

error on wasm-exported notebook related to netcdf4

I am stuck with the following error from the wasm-exported notebook that relies on netcdf4 and xarray.

Plain Text
OSError
This cell raised an exception: OSError('[Errno -128] NetCDF: Attempt to use feature that was not turned on when netCDF was built.: 

This notebook relies on netCDF4 library indirectly through xarray as the driver library for netCDF I/O.
I do not have a deep understanding on how wasm or wasm export works, but it seemed that if I do not directly do import netCDF4, this dependency does not register with wasm.

  1. Is putting in import netCDF4 (although it is not used directly) the best way to specify these indirect dependencies when exporting to wasm or is there a better way?
  1. How can I solve the OSError above? I have been working on this notebook for a while, and this error was not present in the same wasm-exported notebook ~1 month ago. It sounds like something on the pyodide side... but I'm stuck.
Thank you!
A
S
10 comments
1 You can use micropip to install packages explicitly. (import micropip: await micropip.install(“…”))
  1. i am not sure :/ can you try installing an older version of netcdf4?
Just so I understand, the wasm env that gets set up when someone loads the webpage has nothing to do with the pip env I use locally, is that right?
Yea that’s correct
Thank you, I also confirmed this comparing the netCDF4 version in the two wasm. I think this has to do with the latest release of pyodide which upgraded netCDF4 to 1.7.2. (https://pyodide.org/en/stable/project/changelog.html#id2)

For now, the problem would be gone if I can select the pyodide version to be an older one... like 0.26.2 instead of the latest 0.27.x Is this easily done?
or maybe doing explicit pip install <older netcdf> also fixes it. I'll try that
aah.. since netcdf is not a pure python lib, maybe it cannot be pip installed. If there's anyway to downgrade pyodie(?), please let me know!
There isn't any way to downgrade pyodide unfortunately ... I would suggest opening an issue in the Pyodide repo, they are pretty responsive. Sorry for the trouble!
Another option would be to find or build a wheel for an earlier version of netcdf and host it online. Then you can install that wheel explictly with micropip.install(<url-to-wheel>). You might even ask the Pyodide devs if they have any tips for recreating the wheel if that's not something you're comfortable doing. More docs here: https://micropip.pyodide.org/en/stable/project/usage.html
I realized that I goofed on this. Reading notebook_location docs, I thought things should just automagically work like a filesystem whether in python or wasm but I realized that this works because pandas supports remote files.

netcdf doesn't seem to support this reliably.
I tried fsspec but in the end decided to just download the archive hosted on /public.
Add a reply
Sign up and join the conversation on Discord