PyCharm+Docker Dev
Configure an interpreter using Docker
The official guide above use Docker, we use Docker Compose instead.

After set interpreter, there might be some frustrating errors like
cCouldn't refresh skeletons for remote interpreter The docker-compose process terminated unexpectedly: /usr/local/bin/docker-compose -f docker-compose.yml -f .PyCharm2018.3/system/tmp/docker-compose.override.8.yml run --rm --name skeleton_generator_643129755 python Regenerate skeletons
or
can't open file '/opt/.pycharm_helpers/pycharm/django_test_manage.py' + "No such file or directory"
Found a solution:
Then you should clear all pycharm helpers from your docker containers and images:
Specify source root
Sometimes import local modules will counter "unresolved reference" error in PyCharm. usually it's because src code is not in your project root path, so need to adding source folders in settings->project structure.

Debug Django App
PyCharm right-top corner

Add->Django Server:

Then you can enable debug mode.
Debug frustration when use docker-compose
PyCharm with Docker to debug is easy, but...
when we setup python interpreter, if we select Docker, then just follow official guide link at first of PyCharm+Docker Dev.
But we select Docker-Compose. here is a official guide.
When we debug, always not work. then found those articles:
PyCharm remote debug times out
Debugging container with custom entrypoint defined fails
Debugging Compose services with long-lasting entrypoint fails by timeout
if the script takes too long (e.g., wait for postgres, creating a new user, etc...), then the debugger won't properly start.
Seems like if we use entrypoint in docker-compose.yml, and our python launch script not just takes too long, it won't stop actually. so debugger cannot start properly.
remove entrypoint in docker-compose.yml, then put it directly into Dockerfile.
debug works!!

set break point, click debug button, works.

debug celery
see config:

Last updated
Was this helpful?