Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot install Python Package with docker-compose

I am running a Django project with docker. Now I want to install a Python package inside the Docker container and run the following command:

docker-compose django run pip install django-extra-views

Now when I do docker-compose up, I get an error ImportError: No module named 'extra_views'. docker-compose django run pip freeze doesn't show the above package either.

Am I missing something?

like image 494
Sudip Kafle Avatar asked Dec 18 '22 20:12

Sudip Kafle


1 Answers

It looks like you ran the pip install in a one-off container. That means your package isn't going to be installed in subsequent containers created with docker-compose up or docker-compose run. You need to install your dependencies in the image, usually by adding the pip install command to your Dockerfile. That way, all containers created from that image will have the dependencies available.

like image 130
ford Avatar answered Dec 28 '22 11:12

ford