Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

481
Views
Pycharm de integración, Docker Compose y Django Debbuger obtienen un error: /usr/local/bin/python: no se puede encontrar el módulo '__main__'. en ''

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 1

Para configurar el Pycharm que hice:

  • Agregue un intérprete de Python con docker-compose y el contenedor de la aplicación web (Django). Intérprete de Python
  • Agregue una configuración de Django para el proyecto. Proyecto de configuración de Django
  • Agregue una configuración de Ejecutar/Depurador. Ejecutar depurador

ACTUALIZAR

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?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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 .

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!