osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

netcdf read


On Wed, Sep 2, 2015 at 3:23 AM,  <jorge.conrado at cptec.inpe.br> wrote:
> I'm starting in the Python scripts. I run this script:
>
>
> import numpy as np
>
> import netCDF4
>
> f = netCDF4.Dataset('uwnd.mon.ltm.nc','r')
>
>
> f.variables
>
>
> and I had the message:
>
>
> netcdf4.py
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> NameError: name 'netcdf4' is not defined
>
>
> What can I do to solve this.

My crystal ball tells me you're probably running Windows.

On Windows, there's no difference between "netcdf4.py" and
"netCDF4.py", so when you ask Python to "import netCDF4", it finds
your program and imports that. To resolve this, just rename your
script to something else, and delete any "netcdf4.pyc" or related
files. Then try running it under the new name, and you should be fine.

ChrisA