Calmcode - pip-tools: sync

pip-tools sync vs pip install

1 2 3 4 5

Now that we have our requirements.txt and requirements-dev.txt files we're ready to install. You could do that via pip directly, but you may prefer to use pip-sync from pip-tools instead.

python -m piptools sync requirements.txt requirements-dev.txt

By using the sync command you'll not only install packages that aren't installed yet. You will also remove packages that should not be around! This is hugely beneficial when you're often installing packages locally to try them out. You can still keep using python -m pip install for every one-off, but then use the sync command to clean everything up.

To give just one example, imagine installing a new version of scipy which allows you to try out a new feature. It might be that this new version of scipy also demands that you upgrade numpy. This could, by accident, cause issues with scikit-learn. Even when you set the scipy package back to it's original version, this may not clean up the numpy dependency issues. All of this is very tedious to do manually, but the sync command will just handle all of this for your right from the get-go. It's very neat for local development!