Search code examples
pythonpython-3.7netcdf

cannot import name 'dataset' from 'netCDF4' (Windows)


I'm trying to read a netcdf file but it always shows the ImportError: cannot import name 'dataset' from 'netCDF4'.

I have installed the netcdf4 using python using conda install netcdf4 and its have been successfully installed. At the same time I have updated my numpy for it to match my current version of netcdf4. I also have tried installing pip install netcdf4 on the command prompt.

from netCDF4 import dataset
f = dataset('3B43.20170101.7.HDF')

print (Jan01.NETCDF4_CLASSIC)

I expected that it could open the file (netcdf). Thank you!


Solution

  • The correct code is:

    from netCDF4 import Dataset
    f = Dataset('3B43.20170101.7.HDF')