📚
Tech-Posts
  • README
  • Kafka + Maxwell
  • Kafka
  • Docker
  • MySQL connection via SSH
  • Python
    • Django
    • PyCharm+Docker Dev
    • Pip Tools
    • python project with local packages
  • PHP
    • PhpStorm+Docker Dev
  • Cassandra
  • AWS
    • Cheat Sheet
    • Lambda with Kinesis Event Source Mapping
  • AWS DMS
  • Lambda demo function to produce to Kinesis
  • Deploy a static web page with protection of specific static resources on AWS S3
  • Data Engineer
    • Move Salesforce Files out using Pentaho DI
  • A Pentaho DI Project Readme
  • PowerBI
    • Power BI refer to previous row
Powered by GitBook
On this page
  • Configure an interpreter using Docker
  • Specify source root
  • Debug Django App
  • Debug frustration when use docker-compose
  • debug celery

Was this helpful?

  1. Python

PyCharm+Docker Dev

PreviousDjangoNextPip Tools

Last updated 4 years ago

Was this helpful?

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:

docker ps -a | grep -i pycharm | awk '{print $1}' | xargs docker rm
docker images | grep -i pycharm | awk '{print $3}' | xargs docker rmi

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.

docker-compose.yml
services:

    python:
        build: ./docker-config/python
        restart: always
        networks: 
            - message_bridge-network
            - external_api_crm
        volumes: 
            - ./src:/message_bridge
#        entrypoint: /home/docker-entrypoint.sh
Dockerfile
COPY ./docker-entrypoint.sh /home/

CMD ["bash","docker-entrypoint.sh"]

debug works!!

set break point, click debug button, works.

debug celery

see config:

script path and Working directory all in container.

-P solo force worker run in single thread

Configure an interpreter using Docker | PyCharmPyCharm Help
Logo
Configure an interpreter using Docker Compose | PyCharmPyCharm Help
Logo
debug works