LinuxCommandLibrary

pipenv

Manage project dependencies in isolated environments

TLDR

Create a new project

$ pipenv
copy

Create a new project using Python 3
$ pipenv --three
copy

Install a package
$ pipenv install [package]
copy

Install all the dependencies for a project
$ pipenv install
copy

Install all the dependencies for a project (including dev packages)
$ pipenv install --dev
copy

Uninstall a package
$ pipenv uninstall [package]
copy

Start a shell within the created virtual environment
$ pipenv shell
copy

Generate a requirements.txt (list of dependencies) for a project
$ pipenv lock --requirements
copy

SYNOPSIS

pipenv [OPTIONS] COMMAND [ARGS]

PARAMETERS

--help
    Show this message and exit.

--version
    Show the version and exit.

--venv
    Print the virtualenv location.

--py
    Specify which Python version to use.

--where
    Print the project home.

--env
    Print the environment options.

--rm
    Remove the virtualenv. Implies --all.

--bare
    Minimal output.

--completion
    Output completion (shell) code.

--python
    Specify a Python interpreter to use.

--three
    Use Python 3 when creating virtualenv.

--two
    Use Python 2 when creating virtualenv.

--site-packages
    Enable site-packages for the virtualenv.

--clear
    Clears caches (pipenv, pip).

--pypi-mirror
    Specify a PyPI mirror.

DESCRIPTION

Pipenv is a Python virtual environment and package manager. It aims to bring the best of all packaging worlds (bundler, composer, npm, cargo, etc.) to the Python world. It automatically creates and manages a virtualenv for your projects, as well as adds/removes packages from your Pipfile as you install/uninstall packages. It also generates the Pipfile.lock, which is used to produce deterministic builds.

Pipenv is designed to make Python dependency management more accessible, reliable, and reproducible. It streamlines the process of managing project dependencies, eliminating common issues related to conflicting dependencies and version mismatches across different environments. By using Pipenv, developers can easily create isolated environments for their projects, ensuring that each project has its own set of dependencies, independent of the system-wide Python installation or other projects.

CAVEATS

Pipenv requires Python 3.6 or later to run but can manage environments with Python 2.7, 3.5, and newer. It also relies heavily on the `pip` package installer. Ensure both are installed and up-to-date.

COMMANDS

Common Pipenv commands include:
install: Installs packages from Pipfile.
uninstall: Uninstalls packages.
lock: Generates Pipfile.lock.
sync: Installs all packages specified in Pipfile.lock.
run: Runs a given command in the virtualenv.
shell: Spawns a shell within the virtualenv.
graph: Displays the dependency graph.
check: Checks for security vulnerabilities.

PIPFILE AND PIPFILE.LOCK

Pipfile is the configuration file that specifies the project's dependencies. It is intended to replace the requirements.txt file. Pipfile.lock is a snapshot of the project's dependencies, including specific versions and hashes, ensuring reproducible builds across different environments.

HISTORY

Pipenv was created to address the complexities and inconsistencies in managing Python project dependencies. It aims to provide a higher-level, more user-friendly approach compared to tools like virtualenv and pip. The project gained popularity for its simplicity and features like automatic virtualenv management, dependency resolution, and reproducible builds through Pipfile.lock. The project was initially created by Kenneth Reitz, and later supported and maintained by the Python Packaging Authority (PyPA).

SEE ALSO

virtualenv(1), pip(1)

Copied to clipboard