Digitaleclub
Best for you!

How to manage Python projects with Pipenv

Python’s package ecosystem lets you leverage the work of millions of other developers with a simple pip install command. Python’s virtual environments let you isolate projects and their packages for one another.

But juggling environments and packages separately can be unwieldy. Doubly so if your projects have specific package requirements, and you want to focus on development instead of maintenance. What we need is a way to manage environments and packages together. 

Pipenv rolls the management of Python virtual environments and Python packages into a single tool. Pipenv ensures that each project uses the correct version of each package it needs, and that each of those packages has the correct dependencies as well.

Further, Pipenv generates a list of your project’s dependencies that can travel with it, allowing other users or developers to set up the same project in the same way. Other users will also need to install Pipenv to properly set up a Pipenv-managed project, but fortunately, installing and using Pipenv is a breeze. 

How Pipenv works

Typically when you create a Python project and use a virtual environment for its packages, you’re tasked with creating the virtual environment yourself (using the command py -m venv), installing dependencies into it, and tracking the dependencies manually.

Pipenv provides a way to do all of this semi-automatically. The virtual environment for your project is created and managed for you when you install packages via Pipenv’s command-line interface. Dependencies are tracked and locked, and you you can manage development and runtime dependencies separately. You can also migrate from existing old-school requirements.txt files, so you don’t need to tear your project apart and start it over from scratch to use Pipenv well.

Copyright © 2020 IDG Communications, Inc.

Leave A Reply

Your email address will not be published.