8

I need to use the netCDF4 module in order to do some processing. I have followed the steps on this guide and also tried used anaconda2 as recomended on this post.

netCDF4 seems to be installed, as i can run nc-config --version and obtain:

netCDF 4.4.0-rc2

Although, when i try to import netCDF4 in python with:

from netCDF4 import Dataset

It Returns:

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from netCDF4 import Dataset
ImportError: No module named netCDF4

I have all dependencies installed. Cython, numpy and h5py.
It was working last night, before i turned off the PC. When i came back this morning, it just would not work. So if i have netCDF4 installed and can check it's version, how come python is not recognizing it as a module?

Community
  • 1
  • 1
Caio César
  • 221
  • 1
  • 4
  • 12
  • How did you install the package? With anaconda, `conda install netcdf4` is how I recommend obtaining the package. – N1B4 Aug 12 '16 at 14:19
  • Thanks for the suggestion, i'll try next time something happens... And i believe it will. I don't know how or why it worked but... I did a clean uninstall and reinstall of everything i could. h5py, numpy, cython and netcdf. Seemed to work after that. Thanks! – Caio César Aug 12 '16 at 14:22
  • @N1B4 I'm seeing the same error after using `conda install netcdf4` :( – endolith Nov 12 '20 at 14:04

2 Answers2

3

Convert to project interpreter python 2.7 and then run installation command;

pip install netCDF4
Yagmur SAHIN
  • 277
  • 3
  • 3
2

I used

conda install netcdf4

and it works for python 2.7.

Chandler
  • 33
  • 6