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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.150s · 17.9MB
glibcpy 3.10–3.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
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'bagit'
The library is not installed or installed in a different Python environment.
fixRun '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.
fixRecreate 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.
fixRestore 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.
fixUpdate 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.