Install & Compatibility
Where this runs
tested against v0.0.2 · 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.920 runs
installs and imports cleanly · install 0.0s · import 0.027s · 19.4MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 2.4s · import 0.025s · 20MB
17MB installed
● package 17MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Pipfile
✓ from pipfile import Pipfile
PipfileLock
✓ from pipfile import PipfileLock
This quickstart demonstrates how to parse Pipfile and Pipfile.lock contents using the `Pipfile` and `PipfileLock` classes. You can parse from a string using `.parse()` or from a file path using `.load()` (e.g., `Pipfile.load('Pipfile')`). It then shows how to access the various sections and package definitions within these objects.
import os
from pipfile import Pipfile, PipfileLock
# Example Pipfile content (simulating reading from a file)
pipfile_content = """
[packages]
requests = "*"
flask = {version = "==2.0.0", extras = ["dotenv"]}
[dev-packages]
pytest = "*"
[requires]
python_version = "3.9"
"""
# Parse a Pipfile from a string
# For real files, use Pipfile.load('/path/to/Pipfile')
pipfile = Pipfile.parse(pipfile_content)
print("--- Parsed Pipfile ---")
print(f"Python version required: {pipfile.requires.get('python_version')}")
print("Packages (default):")
for name, spec in pipfile.packages.items():
print(f" {name}: {spec}")
print("Dev Packages:")
for name, spec in pipfile.dev_packages.items():
print(f" {name}: {spec}")
# Example Pipfile.lock content (simulating reading from a file)
# (Simplified structure for demonstration)
lock_content = """
{
"_meta": {
"hash": {
"sha256": "..."
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.9"
}
},
"default": {
"requests": {
"hashes": ["sha256:..."],
"version": "==2.28.1"
},
"flask": {
"hashes": ["sha256:..."],
"version": "==2.0.0"
}
},
"develop": {
"pytest": {
"hashes": ["sha256:..."],
"version": "==7.1.2"
}
}
}
"""
# Parse a Pipfile.lock from a string
# For real files, use PipfileLock.load('/path/to/Pipfile.lock')
pipfile_lock = PipfileLock.parse(lock_content)
print("\n--- Parsed Pipfile.lock ---")
print("Locked packages (default):")
for name, details in pipfile_lock.default_packages.items():
print(f" {name}: {details.get('version')}")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pipfile'
The `pipfile` package has not been installed in your current Python environment.
fixInstall the package using pip: `pip install pipfile`
AttributeError: module 'pipfile' has no attribute 'load_from_path'
The `pipfile` module does not expose a top-level `load_from_path` or similar direct utility function. Parsing is typically done via static methods on the `Pipfile` or `PipfileLock` classes.
fixUse `from pipfile import Pipfile` then `pipfile_obj = Pipfile.load('/path/to/Pipfile')` for loading from a file, or `pipfile_obj = Pipfile.parse(content_string)` for parsing from a string. TypeError: 'Pipfile' object is not callable
You are attempting to instantiate the `Pipfile` class directly with a path (e.g., `Pipfile('Pipfile')`) when its constructor is not designed for this. Instead, use its static `load` or `parse` methods.
fixTo load from a file, use `pipfile_obj = Pipfile.load('/path/to/Pipfile')`. To parse from a string, use `pipfile_obj = Pipfile.parse(content_string)`. Upgrade
Version history
0.0.2latest on PyPI · released Mar 11, 2017
Audit
Dependencies
tomlrequiredRequired for parsing TOML-formatted Pipfiles.