Not stopping on breakpoint (DRF project). Python-3.11 & PyCharm 2023.3.4 (Professional Edition)

I am running my DRF project using docker-compose interpreter which is running successfully and can make API calls. But in debug mode, it does not stop at the breakpoint. I am fairly new here. Don't know which config has been missed. I set PYCHARM_DEBUG=True as env variable. and it gives the response of the Added breakpoint:/opt/project/backend/user/views.py - line:20 - func_name:b'post' where I am setting the breakpoint. And also giving me this when the container is about to start. any suggestion !!!

It is working for python-3.10 not in 3.11

2
8 comments

After enabling the No Reload , the debugger is stopping at the breakpoint. From the doc - No reload: If this checkbox is selected, the -- noreload option of the runserver command becomes enabled. If this checkbox is not selected, PyCharm will not select it automatically, which means that debugging in autoreload mode is not possible.

But it will activate the python manage.py runserver --noreload. Will not reload after changing the code. Any better solution?

1

Hi Chowdhurytusharroy!

Please provide screenshot of Preferences | Build, Execution, Deployment | Python Debugger, code sample and more specific steps to reproduce the issue if possible, along with Logs from Help | Collect Logs and Diagnostic Data. Please upload it to https://uploads.services.jetbrains.com and let me know the upload ID.

0

Mikhail Tarabrikov  Upload id: 2024_03_05_EybqbUAQ5zPGp5muyQLZY1 (file: pycharm debugger issue.zip). please check the instruction file.

0

Hi Mikhail Tarabrikov  any update on this? Thanks !!!

0

Hi Chowdhurytusharroy , sorry for the delayed response.

I have created a ticket with limited visibility here: PY-71395 , assigned developer will take a look.

Please follow the issue for updates, feel free to vote and comment, and let us know if you need any help. If you're not familiar with YouTrack, please see https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications

0

Hello, this is still an issue for PyCharm 2024.1 (Professional Edition) Build #PY-241.14494.241, built on March 28, 2024 

Runtime version: 17.0.10+8-b1207.12 aarch64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

I could reproduce it by using an alpine image using Python 3.11 (and higher) and following the official Django tutorial to create a minimal example:

Dockerfile:

FROM python:3.11-alpine3.19

COPY ./requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt

requirements.txt:

asgiref==3.8.1
Django==5.0.4
sqlparse==0.5.0

Following the first part of the Django Tutorial to setup the polls app https://docs.djangoproject.com/en/5.0/intro/tutorial01/

mysite/polls/views.py

from django.http import HttpResponse


def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")  # set a breakpoint here

Then configure a project interpreter On Docker using the above Dockerfile, and create a new run configuration of type Django Server with DJANGO_SETTINGS_MODULE=mysite.settings.

When visiting the endpoint, such as with:

docker exec -it <container id obtained from docker ps> wget localhost:8000/polls/

The debugger doesn't stop at the breakpoint.

Note: The breakpoint does work if running a plain Python script (rather than Django code), or if you have No Reload turned on in the run configuration or if you use a different base OS such as python:3.11-slim or a lower minor version of Python such as 3.10.

Also the PY-71395 is showing a 404 not found. Has a ticket been created for this?

1

I confirm this bug appears also on Intillij 241.17011.79 with runtime 17.0.11+1-b1207.24 amd64, exactly like Mathewchong7  said.

 

0

I had the same problem today. I solved this by closing the IDE and deleting all the .idea and __pycache__ files. I also deleted the run configuration and project interpreter settings, before closing the IDE, then recreated them

I also changed my python version to 3.10 in my Dockerfile, though I do not know if it was part of the solution.

0

Please sign in to leave a comment.