Mod_python not working

I have a python application running on apache via mod_python (Python 2.7.17), /etc/apache2/sites-enabled/000-default.conf:

<VirtualHost *:80>
	ServerAdmin admin@admin.com

    <Directory "/XXX/">
        Options -Indexes
        Require all granted
    </Directory>

    <Directory "/XXX/server/">
        AddHandler mod_python .py
        AddHandler mod_python .pyc
        PythonHandler main
        PythonDebug On
        PythonPath "sys.path+['/XXX/server']"
        Options -Indexes
    </Directory>

	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

I’ve configured the sentry on server/main.py (PythonHandler) file:

import sentry_sdk
sentry_sdk.utils.MAX_STRING_LENGTH = 4096
sentry_sdk.init(
    dsn='YYY',
    traces_sample_rate=1,

    # If you wish to associate users to errors (assuming you are using
    # django.contrib.auth) you may enable sending PII data.
    send_default_pii=True,
)

division_by_zero = 1 / 0

I access the application via url “http://ZZZ/displaysys/server/main.py”.
But it is not logging any error or trace on sentry.
If I use the python shell, it logs the error on sentry:

import sentry_sdk
sentry_sdk.utils.MAX_STRING_LENGTH = 4096
sentry_sdk.init(
    dsn='YYY',
    traces_sample_rate=1,

    # If you wish to associate users to errors (assuming you are using
    # django.contrib.auth) you may enable sending PII data.
    send_default_pii=True,
)
from sentry_sdk import capture_message
capture_message('Test message captured directly')