fsspec — Filesystem Interfaces for Python

raw JSON →
2026.3.0 verified Tue May 12 auth: no python install: verified quickstart: stale

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.

pip install fsspec
error ModuleNotFoundError: No module named 'fsspec'
cause The 'fsspec' library, or a required backend implementation for a specific filesystem (e.g., 'gcsfs' for Google Cloud Storage or 's3fs' for AWS S3), is not installed in the Python environment.
fix
Install 'fsspec' and any necessary backend libraries using 'pip'. Example: pip install fsspec or pip install fsspec gcsfs s3fs.
error ModuleNotFoundError: No module named 'fsspec.asyn'
cause This error occurs when attempting to directly import 'fsspec.asyn', which is an internal module not intended for direct public import.
fix
Avoid directly importing 'fsspec.asyn'. Asynchronous functionalities are typically handled internally by fsspec's high-level functions (like fsspec.open) or exposed through utility functions like fsspec.asyn.sync if explicitly wrapping async code.
error S3 error : Unable to locate credentials
cause When accessing cloud storage like AWS S3 or Google Cloud Storage, 'fsspec' (via 's3fs' or 'gcsfs') cannot find valid authentication credentials in the environment or configured files.
fix
Ensure AWS credentials (e.g., environment variables like AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN, or a ~/.aws/credentials file) or Google Cloud credentials (e.g., GOOGLE_APPLICATION_CREDENTIALS environment variable pointing to a service account key file, or default credentials from a logged-in gcloud user) are properly configured and accessible. For public S3 buckets, pass anon=True to the filesystem constructor.
error FSTimeoutError
cause An operation involving network communication with a remote filesystem exceeded the allocated time limit, often due to slow network connections, large file transfers, or an unresponsive remote service.
fix
Increase the timeout parameter for the specific fsspec operation or the underlying filesystem instance. Additionally, check network connectivity and the availability of the remote service. Example for S3: fs = fsspec.filesystem('s3', client_kwargs={'connect_timeout': 30, 'read_timeout': 60}).
error PermissionError: Access Denied
cause The credentials provided to 'fsspec' (via backends like 's3fs' or 'gcsfs') lack the necessary IAM permissions to perform the requested file or directory operation (e.g., read, write, list) on the specified resource in cloud storage.
fix
Review the IAM policy associated with your AWS credentials or the roles/permissions for your Google Cloud service account. Ensure the policy grants explicit 'Allow' actions (e.g., s3:GetObject, s3:PutObject, s3:ListBucket) on the specific cloud storage bucket and object paths involved in the operation.
gotcha Filesystem instances are cached singletons. fsspec.filesystem('s3', key=K1) and fsspec.filesystem('s3', key=K2) with different credentials may return the same cached instance if arguments hash identically. This can cause silent credential cross-contamination.
fix Call fs_class.clear_instance_cache() when you need a fresh instance, or pass skip_instance_cache=True to fsspec.filesystem().
breaking Calling sync fsspec methods (e.g. fs.ls()) from inside a running asyncio event loop raises NotImplementedError: 'Calling sync() from within a running loop'. This affects Jupyter notebooks, FastAPI handlers, and async frameworks.
fix Inside an async context, instantiate with asynchronous=True and await the private _method coroutines (e.g. await fs._ls()), or use fsspec.asyn.fsspec_loop context manager.
gotcha fsspec.open() returns an OpenFile placeholder — the remote file is NOT opened until you enter a `with` block. Calling .read() on the raw OpenFile object without a context manager will fail.
fix Always use `with fsspec.open(...) as f: f.read(...)` or call of.open() explicitly and close when done.
gotcha Cloud backend packages (s3fs, gcsfs, adlfs) are NOT included in the base fsspec install. Attempting to use fsspec.filesystem('s3') without s3fs raises an ImportError with a hint, but the hint may be missed in automated pipelines.
fix Install the required extra: pip install fsspec[s3], fsspec[gcs], or the specific package. Use fsspec.available_protocols() to check what is installed.
gotcha Async filesystem instances (s3fs, gcsfs) are incompatible with os.fork() (used by PyTorch DataLoader, multiprocessing). After fork, cached instances hold references to dead event loops, causing hangs or cryptic errors.
fix Use multiprocessing with spawn context, or call fs_class.clear_instance_cache() inside the worker initializer after forking.
deprecated Passing `trim` to fsspec.spec.AbstractBufferedFile is deprecated.
fix Remove the trim argument from any AbstractBufferedFile instantiation.
breaking fsspec.asyn.maybe_sync was removed. Older pinned versions of s3fs (<=0.5.2) and other ecosystem libraries that imported maybe_sync will break on recent fsspec.
fix Upgrade s3fs, gcsfs, and adlfs to current releases that are compatible with the same fsspec CalVer month.
pip install fsspec[s3]
pip install fsspec[gcs]
pip install fsspec[ssh]
pip install fsspec[full]
python os / libc variant status wheel install import disk
3.10 alpine (musl) fsspec - - 0.20s 19.3M
3.10 alpine (musl) full - - 0.20s 1.1G
3.10 alpine (musl) gcs - - 0.18s 85.0M
3.10 alpine (musl) s3 - - 0.20s 61.0M
3.10 alpine (musl) ssh - - 0.20s 42.5M
3.10 slim (glibc) fsspec - - 0.13s 20M
3.10 slim (glibc) full - - 0.14s 1.1G
3.10 slim (glibc) gcs - - 0.15s 85M
3.10 slim (glibc) s3 - - 0.14s 63M
3.10 slim (glibc) ssh - - 0.14s 43M
3.11 alpine (musl) fsspec - - 0.30s 21.6M
3.11 alpine (musl) full - - 0.33s 1.2G
3.11 alpine (musl) gcs - - 0.28s 91.5M
3.11 alpine (musl) s3 - - 0.29s 65.3M
3.11 alpine (musl) ssh - - 0.28s 45.6M
3.11 slim (glibc) fsspec - - 0.23s 22M
3.11 slim (glibc) full - - 0.26s 1.2G
3.11 slim (glibc) gcs - - 0.26s 91M
3.11 slim (glibc) s3 - - 0.24s 68M
3.11 slim (glibc) ssh - - 0.24s 46M
3.12 alpine (musl) fsspec - - 0.47s 13.3M
3.12 alpine (musl) full - - 0.53s 1.1G
3.12 alpine (musl) gcs - - 0.48s 82.7M
3.12 alpine (musl) s3 - - 0.47s 56.7M
3.12 alpine (musl) ssh - - 0.49s 37.2M
3.12 slim (glibc) fsspec - - 0.43s 14M
3.12 slim (glibc) full - - 0.53s 1.2G
3.12 slim (glibc) gcs - - 0.45s 82M
3.12 slim (glibc) s3 - - 0.47s 59M
3.12 slim (glibc) ssh - - 0.45s 37M
3.13 alpine (musl) fsspec - - 0.46s 13.0M
3.13 alpine (musl) full - - 0.63s 1.1G
3.13 alpine (musl) gcs - - 0.47s 82.1M
3.13 alpine (musl) s3 - - 0.48s 56.1M
3.13 alpine (musl) ssh - - 0.49s 36.8M
3.13 slim (glibc) fsspec - - 0.43s 13M
3.13 slim (glibc) full - - 0.47s 1.1G
3.13 slim (glibc) gcs - - 0.41s 82M
3.13 slim (glibc) s3 - - 0.42s 58M
3.13 slim (glibc) ssh - - 0.42s 37M
3.9 alpine (musl) fsspec - - 0.14s 18.8M
3.9 alpine (musl) full - - 0.19s 1.0G
3.9 alpine (musl) gcs - - 0.15s 63.6M
3.9 alpine (musl) s3 - - 0.15s 60.0M
3.9 alpine (musl) ssh - - 0.15s 42.7M
3.9 slim (glibc) fsspec - - 0.13s 19M
3.9 slim (glibc) full - - 0.15s 1.1G
3.9 slim (glibc) gcs - - 0.14s 66M
3.9 slim (glibc) s3 - - 0.14s 63M
3.9 slim (glibc) ssh - - 0.14s 43M

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))