Skip to content

Guide · Open source

How to use pipenv: install, manage packages and lock files

Updated · written with AI from the project's own documentation and checked against our catalogue data

Pipenv is a command-line tool for Python projects that creates a virtual environment for each project and records its packages in a Pipfile. It is meant to combine pip and virtualenv into one workflow. This guide shows you how to install it, set up a project, add and remove packages, lock versions and run commands inside the environment.

Pipenvpypa/pipenv · ★ 25k · MIT

Quick start

  1. 1Install Pipenv. Confirm Python 3.10 or above and pip are available, then run pip install --user pipenv.
  2. 2Start in your project. Change into your project directory. Pipenv creates a Pipfile if one does not exist.
  3. 3Install packages. Run pipenv install with a package name. The package is added to the Pipfile automatically.
  4. 4Add dev dependencies. Use pipenv install --dev for tools you only need during development.
  5. 5Generate the lock file. Run pipenv lock to create Pipfile.lock, which records the tested versions and hashes.
  6. 6Run your code. Use pipenv run or pipenv shell to work inside the project's virtualenv.

Install Pipenv with pip

Pipenv needs Python 3.10 or above and pip. The project's README recommends installing it with pip for most users.

Some users prefer pipx instead, which installs the tool in its own isolated environment.

  • Pipenv's README says it can be installed with Python 3.11 and above, including Python 3.15. The README also states Python 3.10 or newer is the minimum for installing Pipenv, so check your version first.
pip install --user pipenv pipx install pipenv

Create a project environment and Pipfile

Pipenv finds your project home by looking for a Pipfile, searching recursively. If no Pipfile exists, it generates one. A virtualenv is created automatically when one does not exist.

To choose which Python version the virtualenv uses, pass the --python flag. The help output shows it as an option that specifies the Python version.

  • Run commands from inside your project directory.
  • Use pipenv --where to see the project home, pipenv --venv for virtualenv location and pipenv --py for the Python interpreter.
pipenv --python 3.7 pipenv --where pipenv --venv pipenv --py

Add, remove and install packages

When you install a package, Pipenv adds it to your Pipfile. When you uninstall one, it is removed from the Pipfile. Running install with no package names installs all packages listed in the Pipfile.

Development-only packages can be installed with the --dev flag, and installing with --dev brings in all dev dependencies.

  • install adds packages and records them in the Pipfile.
  • uninstall removes a package and takes it out of the Pipfile.
  • install with no arguments installs everything in the Pipfile.
  • pipenv install -e . installs a local setup.py into the virtualenv and Pipfile.
pipenv install requests pipenv install --dev pytest pipenv install pipenv uninstall requests

Lock versions for repeatable installs

Pipenv generates a Pipfile.lock, which is used to produce deterministic builds. The lock file records the last tested combination of dependencies, and hashes are documented in it and verified during install.

Other people or machines can recreate the same set of versions from the lock file. The lock command can include pre-releases with the --pre flag.

  • lock generates Pipfile.lock.
  • sync installs all packages specified in Pipfile.lock.
  • update runs lock, then sync.
  • requirements generates a requirements.txt from Pipfile.lock.
  • clean uninstalls all packages not specified in Pipfile.lock.
pipenv lock pipenv lock --pre pipenv sync pipenv update pipenv requirements

Run commands and open a shell

Use run to execute a command installed into the virtualenv without activating it manually. The shell command spawns a shell within the virtualenv.

Pipenv can also inspect your dependencies: graph displays the dependency graph and check looks for security vulnerabilities in installed dependencies.

  • run spawns a command installed into the virtualenv.
  • shell spawns a shell within the virtualenv.
  • graph shows the dependency graph of currently installed packages.
  • check checks installed dependencies for security vulnerabilities.
pipenv run python main.py pipenv shell pipenv graph pipenv check

Enable shell completion

Shell completion is powered by argcomplete. Install the optional dependency first, then add the setup line for your shell.

If you are upgrading from pipenv older than 2026.5.0, the old _PIPENV_COMPLETE environment variable method no longer works. Replace it with the register-python-argcomplete commands.

  • For bash, add the line to ~/.bashrc or ~/.bash_profile.
  • For zsh, add the bashcompinit lines to ~/.zshrc.
  • For fish, add the line to ~/.config/fish/completions/pipenv.fish.
pip install "pipenv[completion]" eval "$(register-python-argcomplete pipenv)"

What people use it for

  • Set up a Python web application so every developer gets the same package versions from Pipfile.lock.
  • Move a project off a hand-maintained requirements.txt and export one with pipenv requirements when needed.
  • Keep a development-only test runner separate from production packages using --dev.
  • Check installed dependencies for known security vulnerabilities with pipenv check.
  • Install a local package in editable mode with pipenv install -e .

Frequently asked questions

Is pipenv free to use?

Pipenv is released under the MIT licence, according to the project's listing. The source code is on GitHub at pypa/pipenv.

What do I need to install pipenv?

You need Python 3.10 or above and pip. The README recommends installing with pip install --user pipenv for most users.

What is the difference between Pipfile and Pipfile.lock?

The Pipfile declares the packages you want. Pipfile.lock records the last tested combination of versions with hashes, which is used for deterministic builds.

Does pipenv replace pip and virtualenv?

Pipenv is meant to combine pip and virtualenv into one workflow, so you no longer need to use them separately. It creates and manages a virtualenv for each project.

How does pipenv compare to Poetry or pip-tools?

The README does not compare pipenv with Poetry, pip-tools, uv or virtualenv, so this guide cannot say which is better. Comparable projects listed for this tool include Poetry, pip-tools, uv and virtualenv.

Why does pipenv shell or install not work after upgrading?

If you upgraded from pipenv older than 2026.5.0, shell completion that used the _PIPENV_COMPLETE variable no longer works. Switch to the register-python-argcomplete commands instead.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Pipenv suits Python application developers who want one set of commands for environments and dependencies, and teams that want hash-checked lock files across Linux, macOS and Windows. It is not a fit for non-Python projects, or for systems that cannot run Python 3.10 or newer; if your pip-tools or Poetry setup already works, the README gives no reason to switch.

Install options & downloads