MERRA2 OpenDAP Bug (python)

Use this Forum to find information on, or ask a question about, NASA Earth Science data.
Post Reply
bcook
Posts: 1
Joined: Fri Sep 12, 2025 12:26 pm America/New_York
Answers: 0

MERRA2 OpenDAP Bug (python)

by bcook » Fri Sep 12, 2025 12:29 pm America/New_York

Hi,

I am following the online instructions to create a python notebook that will allow me to use OpenDap to download MERRA2 data. However, at the end of the retrieval I get an error message that “RuntimeError: Failed to decode variable 'time': NetCDF: Access failure”. Here are the steps I’ve been doing. Please let me know if you would like me to share the python notebook.

(1) I first use Option 3 on this site:

https://disc.gsfc.nasa.gov/information/howto?title=How%20to%20Generate%20Earthdata%20Prerequisite%20Files

to generate and store an Earthdata login token. This works fine using my credentials, and I get confirmation that the token was retrieved and stored in my home directly as an .edl_token.

(2) I then tried running the code example verbatim provided from here (specifically the code in cell 2 beginning with “%%time”):

https://disc.gsfc.nasa.gov/information/howto?keywords=merra-2%20python&title=How%20to%20Access%20MERRA-2%20Data%20using%20OPeNDAP%20with%20Python3%20and%20Calculate%20Daily/Weekly/Monthly%20Statistics%20from%20Hourly%20Data

The code initially runs, but while it is running, I get the following:

syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: HTTP^ Basic: Access denied.
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: HTTP^ Basic: Access denied.
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: HTTP^ Basic: Access denied.
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: HTTP^ Basic: Access denied.
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: HTTP^ Basic: Access denied.
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: HTTP^ Basic: Access denied.
syntax error, unexpected WORD_WORD, expecting SCAN_ATTR or SCAN_DATASET or SCAN_ERROR
context: HTTP^ Basic: Access denied

It runs for a bit longer, and then crashes with the decode time error I mention above.

Thanks for your help.

Filters:

GES DISC - jimacker
User Services
User Services
Posts: 23
Joined: Wed Dec 04, 2024 4:05 pm America/New_York
Answers: 0
Has endorsed: 1 time
Endorsed: 1 time

Re: MERRA2 OpenDAP Bug (python)

by GES DISC - jimacker » Fri Sep 12, 2025 4:46 pm America/New_York

Thank you for your message. Our staff will examine the content of your message and respond as soon as possible.

GES DISC - cbattisto
Subject Matter Expert
Subject Matter Expert
Posts: 24
Joined: Wed Feb 16, 2022 4:38 pm America/New_York
Answers: 0
Has endorsed: 2 times

Re: MERRA2 OpenDAP Bug (python)

by GES DISC - cbattisto » Wed Sep 17, 2025 6:02 pm America/New_York

Hello,
If you are still experiencing this error with Python after the Earthdata Login errors on the 12th, another possible cause is due to a problematic version of the libnetcdf Python library in your environment. This includes versions 4.9.1 and 4.9.2, which have documented compatibility issues with Earthdata Login servers. Versions 4.8.1, 4.9.0, or 4.9.3, will need to be installed.

First, check if you are using either of these problematic versions by running the following Python commands in a notebook or a shell:
import netcdf4 as nc4
nc4.getlibversion()

If either version appears, there are two options to upgrade the library depending on your operating system. If you are running macOS/Linux, simply upgrade to the latest version of netcdf4-python using the command "pip install -U netcdf4". If you are running Windows, please use the command "pip install -U netcdf4==1.6.2".

After that, please try running the notebook again.

Post Reply