Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm "Note that you cannot install any Python packages into Docker-based project interpreters."

in the docs it sayes "Note that you cannot install any Python packages into Docker-based project interpreters." so what is the alternative for that?

The + button to add packages it dimped and I can't click it to add packages, despite it work very well when I use vertualenv instead of docker compose, or docker. enter image description here

  • my configurations enter image description here
like image 621
Ali Husham Avatar asked Sep 21 '25 09:09

Ali Husham


1 Answers

If you're using -- for whatever reason -- a container to run your python interpreter, PyCharm cannot handle updating packages on the container, like it can with local (virtual) environments. This is not too surprising, since containers shouldn't be considered "long lasting." As you pointed out, installing packages directly in the container is one option. Another is using Pycharm's ssh feature to ssh into the container and the run pip to install your needed packages. However, I think the less temporary solution is to use an image with all the packages you need already installed. Two options here: (1) Either pull from a python image on DockerHub with pre-installed apps, e.g.: use FROM python:3.8-slim-buster in your Dockerfile or (2) save your own container with all the packages you want as a new image, by using the docker commit command, eg. docker commit CONTAINER NEW-IMAGE-TAG.

like image 98
gregory Avatar answered Sep 23 '25 00:09

gregory