How to use Docker in Pycharm - 2 - Python Interpreter
After making a docker server and docker container with the image you want to use, there is one more thing you should set up in order to use Pycharm debugger, interpreter and auto-completion.
OS: Linux, Debian, Ubuntu 16.04
You can specify the project Interpreter under Project/Project Interpreter
tab in file/Settings
.
Let’s click the gear icon next to the Project interpreter path like below and click Add
.
If you go click the docker tab, you can see docker servers and images you can use.
There is another post about running a docker server, creating a container, or new docker image from the container in this blog.
Then it is pretty much done.
However, there are some docker images which have virtual environments in them.
Therefore you need to be careful for the Python interpreter path
.
In this case, I wanted to use the
OpenCV-3-4-3
environment in it.
Here is the docker container I created from the image I made last time.
You can see we’re already in the virtual environment named OpenCV-3.4.3-py3
.
Still we need to specify the real python path it uses in Pycharm settings.
I found the python path by
which python
Now we have the path so let’s go back to the settings and insert the path like below.
Finally Pycharm can see all the packages we need.
However, for me, it took a several minutes until I can use the auto-completion in the IDE.
It is such a trivial thing but still hope it can be useful to someone :)
Written with StackEdit.