'Using already existing container python interpreter as PyCharm interpreter

I have latest PyCharm installed. I have a docker container and I want to use its python interpreter as my project interpreter. Note that I don't want PyCharm to create new container from image every time I run my script. What are the steps to do so? If I use container interpreter will PyCharm support code completion for the packages installed in containers interpreter?



Solution 1:[1]

I've submitted a feature request on https://youtrack.jetbrains.com/issue/PY-53854 because this is simply not a feature in PyCharm.

One temporary solution I considered was to ask PyCharm to use the python from the Dockerfile: docker exec -it container-name python, but PyCharm unfortunately doesn't let me set a "command" as a python interpreter for the IDE. It does allow you to set the command for specific run/debug configurations though - so you could use the python interpreter in a running container if you don't want integration with the editor (e.g. import suggestions).


User: Is there a technical reason as to why PyCharm cannot use an interpreter inside an already running container? Or could I expect it to be part of a future release? It would be a very nice feature to have

Jetbrains team: I am not aware of any technical reasons. I couldn't find any feature request for it.

Please feel free to submit a feature request about it to our issue tracker using the link https://youtrack.jetbrains.com/issues/PY and let us know if you need any help.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1