Tengo un problema al usar Pycharm para ejecutar un contenedor Docker para depurar un proyecto Django en MacO.
La configuración de Pycharm funciona bien para ejecutar el proyecto Django dentro de un contenedor Docker. Pero cuando trato de depurar tengo el siguiente problema:
/usr/local/bin/docker-compose -f /Users/claudius/Studies/Pycharm/test-api/docker-compose.yaml -f /Users/claudius/Library/Caches/JetBrains/PyCharm2021.2/tmp/docker-compose.override.1494.yml up --exit-code-from web --abort-on-container-exit web Docker Compose is now in the Docker CLI, try `docker compose up` mongo is up-to-date postgres is up-to-date Recreating test-api_web_1 ... Attaching to test-api_web_1 Connected to pydev debugger (build 212.4746.96) web_1 | /usr/local/bin/python: can't find '__main__' module in '' test-api_web_1 exited with code 1 Aborting on container exit... ERROR: 1 Process finished with exit code 1Para configurar el Pycharm que hice:



Según lo solicitado por @Thy y @DanielM, ese es el Dockerfile :
FROM python:3.9.1 AS backend ARG DJANGO_ENV ENV DJANGO_ENV=${DJANGO_ENV} \ # pip: PIP_NO_CACHE_DIR=off \ PIP_DISABLE_PIP_VERSION_CHECK=on \ PIP_DEFAULT_TIMEOUT=100 \ # poetry: POETRY_VERSION=1.1.7 \ POETRY_VIRTUALENVS_CREATE=false # Set work directory WORKDIR /pysetup COPY ./pyproject.toml ./poetry.lock* /pysetup/ RUN pip install "poetry==$POETRY_VERSION" RUN poetry install --no-interaction --no-ansi # Copy project COPY . /pysetup/ Y ese es el docker-compose.yaml :
# docker-compose.yml version: '3.8' services: db: image: postgres:12.0-alpine env_file: .env ports: - "5432:5432" container_name: postgres mongodb: image: mongo:5.0.5 env_file: - .env ports: - "27017:27017" container_name: mongo web: build: . command: ["python", "manage.py", "runserver", "0.0.0.0:8000"] env_file: - .env volumes: - .:/test-api-volume ports: - 8000:8000 stdin_open: true tty: true depends_on: - db - mongodb¿Alguien tiene alguna sugerencia?
Después de que no pude depurar con Docker, intenté depurar usando entornos virtuales y recibí el mismo mensaje:
Connected to pydev debugger (build 212.4746.96) /usr/local/bin/python: can't find '__main__' module in '' Entonces, un compañero de trabajo sugirió actualizar el IDE Pycharm.
Y simplemente funcionó. Ahora puedo depurar con Docker o usar entornos virtuales.
En otras palabras, el problema era que IDE Pycharm Professional version 2021.1.1 running on MacOS Monterey .