简体   繁体   中英

Error using netCDF4 python module

I am using netCDF4 and python 3.4.

I run the following line of code in order to start writing a new netCDF file that I will be filling with data later in my code following netcdf4 documentation. I however keep getting this error...

File "netCDF4.pyx", line 1466, in netCDF4.Dataset.__init__ (netCDF4.c:19692) RuntimeError: Permission denied

from netCDF4 import Dataset
rootgrp = Dataset('test.nc', 'w', format='NETCDF4')

Any help will be most appreciated.

The "Permission denied" part of the error leads me to believe you don't have permissions to write to the current directory (wherever you are when you run your script).

Check your permissions and/or try giving a full path to put the file in a directory you know you can write to.

dataset.close()

or close ide and delete file 'netCDF4.pyx'

maybe a file exist there, so can't write it.

In my case, this error arises when I am running python by crontab.

The solution is to add following line at the beginning of crontab file.

HDF5_USE_FILE_LOCKING=FALSE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM