Registry / serialization / python-fsutil

python-fsutil

JSON →
library0.17.0pypypi✓ verified 25d ago

python-fsutil provides a collection of high-level, convenient utilities for common file-system operations, simplifying tasks like reading, writing, copying, moving, and deleting files and directories. It aims to offer a more Pythonic and less verbose alternative to direct `os` and `shutil` module usage. The current version is 0.16.1, and the library maintains an active release cadence with minor updates every few months.

pip install python-fsutil
INSTALL
IMPORT
SIG · PYTHON-FSUTIL
P
python-fsutil
serializationpythonv0.17.0
Install
1.6s avg
Import
70ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.17.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.074s · 18MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.066s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

fsutil
import fsutil

This quickstart demonstrates basic file and directory operations: creating a temporary file and directory, writing and reading file content, checking existence, getting file size, and finally cleaning up both the file and the created directory.

import fsutil import os import tempfile import pathlib # Create a temporary directory for demonstration with tempfile.TemporaryDirectory() as tmp_dir: tmp_path = pathlib.Path(tmp_dir) file_path = tmp_path / "my_test_file.txt" content = "Hello, fsutil!\nThis is a test file." # 1. Write content to a file (atomic operation for safety) fsutil.write_file(file_path, content, encoding="utf-8", atomic=True) print(f"File written to: {file_path}") # 2. Read content from the file read_content = fsutil.read_file(file_path, encoding="utf-8") print(f"Content read:\n---\n{read_content}---") assert read_content == content # 3. Check if file exists assert fsutil.file_exists(file_path) # 4. Get file size size = fsutil.get_file_size(file_path) print(f"File size: {size} bytes") # 5. Create a nested directory new_dir_path = tmp_path / "parent_dir" / "child_dir" fsutil.create_dir(new_dir_path) print(f"Directory created: {new_dir_path}") assert fsutil.dir_exists(new_dir_path) # 6. Remove the file fsutil.remove_file(file_path) assert not fsutil.file_exists(file_path) print(f"File removed: {file_path}") # 7. Remove the directory (recursively) fsutil.remove_dir(tmp_path / "parent_dir") assert not fsutil.dir_exists(tmp_path / "parent_dir") print(f"Directory removed: {tmp_path / 'parent_dir'}") print("fsutil quickstart completed successfully.")
Debug
Known issues
gotchaAtomic file operations (fsutil.write_file with `atomic=True`) had known issues with preserving file permissions and exhibited inconsistent behavior on Windows in versions prior to 0.16.0. This could lead to incorrect permissions or data loss on specific platforms, or race conditions if not handled carefully.
fix
Upgrade to `python-fsutil` version 0.16.0 or newer to ensure robust and cross-platform atomic file operations with improved permission handling and Windows compatibility.
affects: < 0.16.0
gotchaSearch methods like `fsutil.search_files` and `fsutil.search_dirs` exhibited incorrect behavior when dealing with relative paths and sometimes failed to normalize paths using OS-specific separators in versions prior to 0.16.1. This could lead to unexpected results or missed files/directories in search operations.
fix
Update to `python-fsutil` version 0.16.1 or newer for corrected and consistent path handling in search operations, especially when using relative paths or expecting OS-specific path separators.
affects: < 0.16.1
gotchaThe `fsutil.join_filename` method could return incorrect or unexpected values when the `basename` or `extension` arguments were empty in versions prior to 0.14.0. This might affect applications relying on precise filename construction from components.
fix
Upgrade to `python-fsutil` version 0.14.0 or newer to ensure correct behavior of `join_filename` with empty name components.
affects: < 0.14.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'fsutil'
The `python-fsutil` package is not installed in the current Python environment or is not accessible.
fix
pip install python-fsutil
AttributeError: module 'fsutil' has no attribute 'rmdir'
The user is attempting to call a function named `rmdir` which does not exist directly in the `fsutil` library, likely confusing it with `os.rmdir`. The correct function for removing a directory is `fsutil.remove_dir`.
fix
fsutil.remove_dir('/path/to/directory')
ImportError: cannot import name 'read_text' from 'fsutil'
The user is trying to directly import a function named `read_text` from the `fsutil` package, which does not exist. The correct function for reading file content is `read_file`.
fix
from fsutil import read_file
TypeError: expected str, bytes or os.PathLike object, not int
A file system utility function in `fsutil` that expects a path (string, bytes, or path-like object) was called with an argument of an invalid type (e.g., an integer).
fix
fsutil.read_file('/path/to/file.txt') # Ensure path argument is a string or pathlib.Path object
Upgrade
Version history
0.17.0latest on PyPI · released Jul 7, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
Resources
python-fsutil — pip install python-fsutil · libregistry