How to add a new pip package to the project?

I'm working in a project generated by cookiecutter-django localy using docker, I wanted to add new packeges, what is the best aproche to perform this?

I'm actually copying the version of the package and pasting into the base requirements file and building the local.yaml contener again and it's seams to be rebuilding the entire containers in the project instead of building only the container that changes has been detected. So i don't if my aproche is the best, so please help me acheive this

Given how you tagged the question, I assume you want to add a new Python package to a project that was generated using cookiecutter-django.

I think that the way you're doing it is correct. To be 100% clear, you need to:

  1. Edit the requirement file where you want it installed:
    • local.txt for local only
    • production.txt for production only
    • base.txt for both
  2. Rebuild your containers: docker-compose -f local.yml build
  3. Restart your containers: docker-compose -f local.yml up -d

The 2nd step may feel a bit heavy, as it would reinstall all the Python packages, not the just the new one, but AFAIU that's how Docker works.

Hope that helps!

Back to Top