notebook icon indicating copy to clipboard operation
notebook copied to clipboard

pdb, environment setup, and addition of "breakpoint" in .ipynb file(s)

Open kevomac12 opened this issue 10 months ago • 2 comments

Description

Screenshot of the "User variables for Kevin" environment setting 'pythonbreakpoint' all caps, value is 'pdb.set_trace'! Image Having done as suggested to be able to set 'breakpoint() in my .ipynb script! Execution of the script did not result in a halt, & entry into "ipdb>".

Reproduce

  1. Edit the 'user variables of kevin in Environment Variables window
  2. Add 'PYTHONBREAKPOINT' to the 'Variable' section, next add to the 'Value' side, the string in single quotes, 'pdb.set_trace' statement.
  3. Add the string no quotes [breakpoint()]
  4. From the Jupyter Notebook, run the script that contains the above "3)" step.
  5. Observe output.

Python.org:

(https://docs.python.org/3/using/cmdline.html#envvar-PYTHONBREAKPOINT) Consulted the 'python.org' site for the proper syntax of the use of 'PDB'!

Expected behavior

title="I'm a tooltip">My lines in the script Tic Tac Toe.

from IPython.display import clear_output

import pdb;

import sys;

from IPython import embed

import os

os.environ['PYTHONBREAKPOINT'] = 'pdb.set_trace'

# DEBUGGING environment variables for kevin...

print(os.getenv('PYTHONBREAKPOINT'))

Well, I expected execution to halt when the script reached and executed "breakpoint()" in my script!

def game_message():

message_string = "\nThis is the Tic-Tac-Toe game, & you will\

see the standard board (above) layout of
three rows, with three boxes per row! On
the game board (below) top-left box is
'1' and the bottom-right box is '9', and please,
only Capital X or O.\n
\nYou will select a box number to place your X or O into!\n
'X' is player1, and 'O' is player2!\n"

print(message_string)
breakpoint()
<p style="color:red;">breakpoint() I expected this: "ipdb>", didn't happen!</p>

game_message()

END game_message()

def display_game_board():

gameOn = True
breakpoint()
<p style="color:red;">breakpoint() I expected this: "ipdb>", didn't happen!</p>

Context

Windows 11, 24H2

Chrome version 133.0.6943.60 (Official Build) (64-bit)

Jupyter Notebook Version: 7.0.8

Troubleshoot Output
Paste the output from running `jupyter troubleshoot` from the command line here.
You may want to sanitize the paths in the output.
Command Line Output
Paste the output from your command line running `jupyter notebook` here, use `--debug` if possible.
Browser Output
Failed to load resource: the server responded with a status of 404 Pierian_Data_Logo.png:1           
(Not Found)Understand this errorAI
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'type') 4234.bundle.js:1 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'type')
    at _e (4234.bundle.js:1:109624)
    at 4234.bundle.js:1:108043
    at Array.forEach ()
    at l (4234.bundle.js:1:108002)
    at c (4234.bundle.js:1:109100)
    at a (409.bundle.js:1:2625)
    at e.emit (409.bundle.js:1:2354)
    at o.emit (409.bundle.js:1:334)
    at ce._onCellInViewportChanged (4234.bundle.js:1:66622)
    at a (409.bundle.js:1:2625)Understand this errorAI
523.fa256ee012d38a89b65a.js:1 Uncaught (in promise) TypeError: e.metadata.get is not a function
    at x._loadFromNotebook (523.fa256ee012d38a89b65a.js:1:5542)
    at x.restoreWidgets (523.fa256ee012d38a89b65a.js:1:4202)Understand this errorAI
202-Milestone%20Proje…%20Workbook.ipynb:1 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was receivedUnderstand this errorAI

kevomac12 avatar Feb 09 '25 06:02 kevomac12

Hi @kevomac12, thanks for opening this issue! An issue related to this has been previously reported in ipykernel: https://github.com/ipython/ipykernel/issues/897. There are some mentioned workarounds but it looks like this issue is still present.

However, I wanted to mention some alternative debugging options that might be useful:

RRosio avatar Feb 10 '25 17:02 RRosio

Thanks, but what is the March 2025 status for this 'feature', would you know why it's still not fixed?

kevomac12 avatar Mar 18 '25 23:03 kevomac12