ActiveState Platform Demo: Virtualenv vs Pipenv
This year, the Python community has welcomed pipenv as an improved way to create virtual environments, especially when it comes to dependency management.
For example, previously, in order to create virtual environments so you could run multiple projects on the same computer you’d need:
- A tool for creating a virtual environment (like virtualenv or venv)
- A utility for installing packages (like pip or easy_install)
- A tool/utility for managing virtual environments (like virtualenvwrapper or pyenv)
- All the commands associated with the libraries used
Pipenv includes all of the above, and more, out of the box. It essentially gives you package management and virtual environment support in a single tool. Learn more in this blog.
A virtual environment is a self-contained sandbox environment just for your application. It only has the packages you specify and keeps them distinct from the system ones, which is crucial for deployment and development.
Pipenv combines pip and virtualenv, providing extended functionality in a single tool endorsed by the Python Software Foundation as the new community standard. You can initialize an environment and manage dependencies using commands like:
pipenv install pipenv lock
For a deterministic build, Pipenv generates a lock file, which contains a fully resolved dependency tree for the project. While it provides many benefits, resolving dependency conflicts may require manual intervention.