netCDF4 import not being found by Python

Caio César picture Caio César · Aug 12, 2016 · Viewed 21.1k times · Source

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?

Answer

Yagmur SAHIN picture Yagmur SAHIN · Feb 6, 2019

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

pip install netCDF4