Python Sentry Alerts not working

This is probably me doing something stupid but I am not getting any errors from sentry. Trying to trigger it from ipython
>
> In [1]: import sentry_sdk
> …:
>
> In [2]: sentry_sdk.init(“https://xxx@sentry.io/xxx”)
> …:
> Out[2]: <sentry_sdk.hub._InitGuard at 0x10a842d10>
>
> In [3]: division_by_zero = 1 / 0
> …:
> ---------------------------------------------------------------------------
> ZeroDivisionError Traceback (most recent call last)
> in
> ----> 1 division_by_zero = 1 / 0
>
> ZeroDivisionError: division by zero

We explicitly do not send any uncaught errors from the REPL to Sentry. Otherwise you would get an email for every typo you make. Try calling capture_exception or capture_message explicitly, that should always work

Calling capture_exception and capture_message directly didn’t help either.

I’m using sentry-sdk==0.14.2 and the following IPython console:
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
Type ‘copyright’, ‘credits’ or ‘license’ for more information
IPython 7.13.0 – An enhanced Interactive Python. Type ‘?’ for help.

What I observe is the following.

One statement is setup:
import sentry_sdk
from sentry_sdk import capture_exception
from sentry_sdk import capture_message
sentry_sdk.init(“https://******”, debug=True)

The followup statement is:
capture_message(‘Test message captured directly’)

and this leads to nothing.

However when I execute everything as single statement (init+capture_message) the event fires and captured on the server.

When I use legacy Raven and create client in one statement and use client to capture exception in follow-up statements - all works fine.

@oleksandr could this be a IPython speciality? How does the regular python REPL work for you?

@untitaker yes, it is IPython’s works differently.
using regular python REPL works just fine (with explicit captures of course).