I am running a Django project with docker. Now I want to install a Python package inside the Docker container and run the following 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.