netcdf4-python icon indicating copy to clipboard operation
netcdf4-python copied to clipboard

Undefined symbol : pfnc_inq_vardimid during import netCDF4

Open fparadiss opened this issue 4 months ago • 4 comments

Dear devs,

Here's the information about my build :

  • Python: 3.11.5
  • netCDF4-python: 1.7.2 (same result with pip install and from source via pip install .)
  • netcdf-c: 4.9.3 (custom build, with nc_complex enabled)
  • HDF5: 1.14.6
  • OS: Rocky Linux 8.10

Trying to install netcdf4-python from : pip install netCDF4 or from source code : pip install . I get the following error when trying to import netCDF4 in python although there is no error during the installation :

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/fparadis/pyenv/lib/python3.11/site-packages/netCDF4/__init__.py", line 3, in <module>
    from ._netCDF4 import *
ImportError: /home/fparadis/pyenv/lib/python3.11/site-packages/netCDF4/_netCDF4.cpython-311-x86_64-linux-gnu.so: undefined symbol: pfnc_inq_vardimid

From my current understanding, these symbols are defined inside nc_complex which should be automatically added during the installation of netCDF4-python. However, I've also tried to install manually nc_complex and link them using LD_LIBRARY_PATH but to no success. Using nm -D, I can see the symbols pfnc_inq_vardimid is correctly defined in libnc_complex.so.

As I don't need nc_complex in my installation, I was wondering if it is either possible to deactivate nc_complex or how to correctly link the symbols to it.

Thanks in advance, Félix

fparadiss avatar Aug 04 '25 21:08 fparadiss

@ZedThree ?

jswhit avatar Aug 05 '25 22:08 jswhit

When you say 'netcdf-c: 4.9.3 (custom build, with nc_complex enabled)' do you mean that it's a modified version of the C-lib with nc_complex included? If so, I suspect that there is a conflict between the two versions of nc_complex (the one in the C lib and the one included in the python module).

jswhit avatar Aug 05 '25 22:08 jswhit

I thought that we build nc_complex as part of the Cython build? https://github.com/Unidata/netcdf4-python/blob/57b9a8086644cb339bf51ade38a120cec097a2ec/setup.py#L428-L437

So I don't think you need to have built it separately.

ZedThree avatar Aug 06 '25 08:08 ZedThree

Also, I cannot reproduce that with the built wheel. Your pip install is probably from source, right? If so, something is amiss with your build.

ocefpaf avatar Aug 06 '25 13:08 ocefpaf