Pip, Pipenv, Poetry or Conda
--
Which package manager to use in 2020?
Intro
The majority of developers when they get introduced to python, most probably pip
is first tool they learn to use to manage packages. I have used pip
for the first couple of years working as a developer and at that time there were almost no alternatives until that has changed.
The Pip
pip comes by default with python and installing packages with pip
is pretty straight-forward,
Just pip it …
$ pip install [package-name]
If you need to keep you packages organised, and you don’t want to install project packages in the user or systems path, probably you will need to use a virtual environment
.
$ python3 -m venv venv
Then you need to activate it
example (linux/unix)
$ source venv/bin/activate
And then de-activate when finished
$ deactivate
Next step would be to keep track of the installed packages
$ pip freeze >> requirements.txt
And it would be of great help when someone else needed to install this project somewhere else.
Are we finished? Well, not yet, we need to make sure that we resolve our dependencies as well.
So we can use pip-tools
which is a combination of pip-compile
and pip-sync
.
So just to install a package with pip
you will need 4-5 steps to achieve that which in my opinion is a lot of hassle.
Conda
Conda is great package management tool for python, it will take care of package management and virtual environment for you.
Install
You can install conda on MacOs, Windows or Linux.
Conda is Python agnostic (although it is written in python). The biggest advantage over the rest of package managers is that you can install pretty much install anything from C libraries to R packages or even binaries.
Usage
to create a new virtualenv
$ conda create --name venv