Registry / serialization / pipfile

pipfile

JSON →
library0.0.2pypypi✓ verified 84d ago

The `pipfile` library serves as the canonical reference and parsing implementation for the Pipfile and Pipfile.lock file formats. It is a low-level library primarily intended for use by other tools (such as Pipenv) to programmatically read, write, and manipulate these dependency definition files. The current version is 0.0.2, and its release cadence is very infrequent, reflecting its role as a stable specification parser rather than a frequently updated application.

pip install pipfile
INSTALL
IMPORT
SIG · PIPFILE
P
pipfile
serializationpythonv0.0.2
Install
2.4s avg
Import
26ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.027s · 19.4MB
glibc
py 3.103.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')}")
Debug
Known issues
gotchaThis library (`pipfile`) is the specification parser for Pipfiles and Pipfile.lock, not the end-user command-line tool. If you are looking to manage Python project dependencies, install packages, and manage virtual environments, you should use `pipenv`.
fix
For end-user dependency management, install and use `pipenv` (`pip install pipenv`). This library is for programmatic interaction with the file format itself.
affects: 0.0.1+
gotchaThe `pipfile` library has an extremely low release cadence (current version 0.0.2 from 2017). While the underlying Pipfile specification is actively maintained, this specific library is considered stable for its current parsing capabilities and is unlikely to receive frequent new features or updates.
fix
Do not expect rapid development or new features from this library. Its purpose is to provide a stable, consistent parser for the file format. For new functionality related to Pipfiles, refer to `pipenv` or other tools that consume this library.
affects: 0.0.1+
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pipfile'
The `pipfile` package has not been installed in your current Python environment.
fix
Install 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.
fix
Use `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.
fix
To 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.
Agent activity
14 hits · last 30 days
node
12
Resources
pipfile — pip install pipfile · libregistry