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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With