fsspec — Filesystem Interfaces for Python

2026.3.0 · active · verified Sat Mar 28

Filesystem Spec (fsspec) provides a unified, Pythonic interface to local, remote, and embedded file systems and bytes storage — including S3, GCS, Azure, HTTP, SFTP, memory, and more. It is the file-system abstraction layer used internally by Dask, pandas, PyArrow, Zarr, and many others. The current version is 2026.3.0, following a monthly calendar-versioning (CalVer) release cadence tied to the YYYY.MM.PATCH scheme.

Warnings

Install

Imports

Quickstart

Open a remote HTTP file, read/list a local filesystem, and demonstrate the memory filesystem — all with the same API.

import os
import fsspec

# 1. Open any URL transparently (protocol auto-detected from URL)
with fsspec.open(
    "https://raw.githubusercontent.com/fsspec/filesystem_spec/master/README.md",
    "rt",
) as f:
    first_line = f.readline()
    print("README first line:", first_line.strip())

# 2. Use fsspec.filesystem() for repeated operations on one backend
fs = fsspec.filesystem("memory")  # in-process, no I/O
fs.mkdir("/mydir")
with fs.open("/mydir/hello.txt", "wt") as f:
    f.write("Hello from fsspec!")
with fs.open("/mydir/hello.txt", "rt") as f:
    print(f.read())
print("Files:", fs.ls("/mydir"))

# 3. S3 example (needs pip install fsspec[s3])
# Uses env-var credentials — safe pattern for agents
# aws_key = os.environ.get('AWS_ACCESS_KEY_ID', '')
# aws_secret = os.environ.get('AWS_SECRET_ACCESS_KEY', '')
# fs_s3 = fsspec.filesystem('s3', key=aws_key, secret=aws_secret)
# print(fs_s3.ls('my-bucket/'))

# 4. Zarr-style key-value mapping over any backend
mapper = fsspec.get_mapper("memory://zarr-root/")
mapper["chunk-0"] = b"\x00" * 128
print("Mapper keys:", list(mapper))

view raw JSON →