Unable to load netCDF4 module

Hi, I am trying to read the netCDF4 module in Jupyterlab environment, after I have successfully loaded xp65 pre-installed conda packages. However, Jupyter says netCDF4 is not found, even when I checked that package is found on conda list. Most probably there are missing libraries required to run netCDF4.

Has anyone faced the same issue or can rectify the missing libraries?

Hi @xcmarvin, could you share the error messages you get when you try to load/use the netcdf package from xp65?

Hi, it’s basically no module is found error. I didn’t have the issue when I load others like numpy, matplotlib etc.

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Input In [6], in <cell line: 1>()
----> 1 import netCDF4 as netCDF4
      2 from netCDF4 import Dataset
      3 import matplotlib.pyplot as plt

ModuleNotFoundError: No module named 'netCDF4'

Thanks for that! I netcdf should be installed in all the xp65 environments so perhaps you haven’t set it up correctly in your ARE session. Can you run:

import sys
print(sys.executable)

it should point to something like /g/data/xp65/public/apps/med_conda_scripts/analysis3-25.09.d/bin/python

Yes, it seems the environment being used is wrong. I got pointed to /apps/jupyterlab/3.4.3-py3.9/bin/python. Do you know how can I switch to the correct environment?

This probably means you haven’t setup your ARE session appropriately. You can follow these instructions: conda/analysis3 Python Environment - ACCESS-Hive Docs specifically the storage and advanced module steps. You’ll also want to make sure you’ve joined the xp65 project on NCI.

Thanks for the tip! I managed to set up the ARE session correctly using the advanced options and specifying the right kernel. Just curious, I chose one of the kernels with “edge” name and failed to load netCDF4. What’s the difference between the kernels with “edge” and those without?

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[16], line 1
----> 1 from netCDF4 import Dataset

File /g/data/xp65/public/apps/med_conda/envs/analysis3_edge-25.09/lib/python3.11/site-packages/netCDF4/__init__.py:3
      1 # init for netCDF4. package
      2 # Docstring comes from extension module _netCDF4.
----> 3 from ._netCDF4 import *
      4 # Need explicit imports for names beginning with underscores
      5 from ._netCDF4 import __doc__

ImportError: /g/data/xp65/public/apps/med_conda/envs/analysis3_edge-25.09/lib/python3.11/site-packages/netCDF4/../../../././libucc.so.1: undefined symbol: ucs_config_doc_nop

Great glad to know that worked. Do you mind tagging this topic with help? So others may find it in the future.

As for the edge naming - that edge for the latest month e.g. 12 for this month, means that the packages can change throughout that month. After the month is over, it gets turned into the non-edge module and packages will no longer change.

So 09 is a bit behind, you could try analysis_25.11 instead and see if the error is still there.

1 Like