Registry / serialization / bagit
library1.9.0pypypi✓ verified 85d ago

Create and validate BagIt packages, a hierarchical file packaging format for digital preservation. This library supports BagIt version 0.97 and offers strong validation. Current stable release is 1.9.0 (released March 2023). It is mature and well-maintained.

pip install bagit
INSTALL
IMPORT
SIG · BAGIT
B
bagit
serializationpythonv1.9.0
Install
3.5s avg
Import
146ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.9.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.150s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 3.5s · import 0.142s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

bagit
import bagit
from bagit import Bag
The main module is bagit, not Bag. Bag is a class inside the module.
Bag
from bagit import Bag
import bagit.Bag
You import the class directly from the module.

Create a BagIt bag and then validate it.

import bagit import os # Create a bag bag_path = '/tmp/mybag' os.makedirs(bag_path, exist_ok=True) with open(os.path.join(bag_path, 'test.txt'), 'w') as f: f.write('hello') bag = bagit.make_bag(bag_path, checksums=['md5', 'sha256']) print('Bag created:', bag) # Validate an existing bag valid, messages = bagit.validate_bag(bag_path) if valid: print('Bag is valid') else: print('Errors:', messages)
bagit --version
Debug
Known issues
breakingIn bagit 1.8.0+, the default checksum algorithm changed from MD5 to SHA256. Scripts relying on MD5 must explicitly pass checksums=['md5'].
fix
When making a bag, specify checksums=['md5'] if you need backward compatibility with older tools.
affects: >=1.8.0
gotchaThe validate_bag function modifies the bag in place by writing fetch.txt if any file is missing from the payload. This is unexpected and can cause side effects.
fix
Use validate_bag(..., fast=True) to skip remote file validation, or use check_completeness() separately.
affects: all
gotchaPaths in bagit are case-sensitive on Linux but not on macOS/Windows. This can cause validation failures when moving bags between systems.
fix
Ensure all file paths within the bag use consistent casing.
affects: all
deprecatedPython 2 support ended in bagit 1.9.0. If you need Python 2 compatibility, use bagit < 1.7.0.
fix
Upgrade to Python 3, or pin bagit to 1.6.0 for Python 2.
affects: >=1.9.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'bagit'
The library is not installed or installed in a different Python environment.
fix
Run 'pip install bagit' in the correct Python environment (check with which python or python -m pip).
ValueError: No manifest declarations for ... but file found in payload.
The payload directory contains files not listed in the manifest.
fix
Recreate the bag with bagit.make_bag() or manually add entries to manifest-*.txt.
bagit.BagError: Bag validation failed: missing expected file ...
A file declared in the manifest is missing from the payload directory.
fix
Restore the missing file or regenerate the bag.
TypeError: make_bag() got an unexpected keyword argument 'checksums'
Using an older version of bagit (<1.5) that does not support the checksums parameter.
fix
Update to latest bagit: pip install --upgrade bagit
Upgrade
Version history
1.9.0latest on PyPI · released Jun 13, 2025
Audit
Dependencies
sixrequiredPython 2/3 compatibility, used in internal utilities.
setuptoolsoptionalRequired for installation and metadata handling.
Agent activity
27 hits · last 30 days
node
22
Amazon
1
OpenAI (training)
1
Resources
bagit — pip install bagit · libregistry