Copernicus Marine Data Store Client

raw JSON →
2.4.0 verified Sat May 09 auth: no python

Python library and CLI for accessing and downloading marine data from the Copernicus Marine Service (CMEMS). Version 2.4.0 requires Python >=3.10. Released under Apache-2.0, with regular updates.

pip install copernicusmarine
error copernicusmarine.login() missing or AttributeError: module 'copernicusmarine' has no attribute 'login'
cause In v2.x, the login function was removed. Users upgrading from v1.x try to call copernicusmarine.login().
fix
Remove login() call. Pass username and password as arguments to subset() or set environment variables COPERNICUSMARINE_USERNAME and COPERNICUSMARINE_PASSWORD.
error ImportError: cannot import name 'open_dataset' from 'copernicusmarine'
cause Direct import of open_dataset from copernicusmarine is deprecated in v2.3+ and removed in some versions.
fix
Use copernicusmarine.open_dataset() or switch to copernicusmarine.subset().
error copernicusmarine.exceptions.CredentialsException: No credentials provided
cause Authentication is required but no username/password given via parameters or environment variables.
fix
Set COPERNICUSMARINE_USERNAME and COPERNICUSMARINE_PASSWORD environment variables, or pass username and password to the function.
breaking In v2.x, the login function was removed; you must pass credentials directly to subset() or set environment variables COPERNICUSMARINE_USERNAME and COPERNICUSMARINE_PASSWORD.
fix Use authentication via parameters or env vars; do not use copernicusmarine.login().
deprecated The open_dataset() function is deprecated in v2.3+ and will be removed in v3.0. Use the subset() method with appropriate parameters.
fix Replace open_dataset() calls with subset() for file-based access or use xarray with fsspec via the Copernicus Marine toolbox.
gotcha The library requires an active internet connection and authentication even for describe() if you are behind a firewall. The CLI may cache credentials in ~/.copernicusmarine.
fix Ensure network access and set COPERNICUSMARINE_USERNAME and COPERNICUSMARINE_PASSWORD environment variables for non-interactive use.
gotcha When using subset() with a large geographic or temporal range, the request may time out or generate a very large file. Prefer multiple smaller requests.
fix Split the request into smaller chunks or use the MOTU API directly for heavy downloads.
conda install -c conda-forge copernicusmarine

Authenticate and download a subset of global ocean physics data as NetCDF.

import copernicusmarine
import os

# Describe available datasets (requires internet)
copernicusmarine.describe()

# Download a sample dataset (with authentication, using env vars)
copernicusmarine.subset(
    dataset_id="cmems_mod_glo_phy_my_0.083deg_P1M-m",
    variables=["thetao"],
    minimum_longitude=0,
    maximum_longitude=10,
    minimum_latitude=40,
    maximum_latitude=45,
    start_datetime="2021-01-01T00:00:00",
    end_datetime="2021-01-01T00:00:00",
    username=os.environ.get("COPERNICUSMARINE_USERNAME", ""),
    password=os.environ.get("COPERNICUSMARINE_PASSWORD", ""),
    output_filename="sample_data.nc"
)