Debug a Python program

Before you begin, verify that your Python environment meets the Python debugging supported platforms and requirements.

The Python Session window of the Session Editor supports single-process native Python debugging. To learn more, see Launch single-process Python programs. To launch parallel native Python programs, see Launch parallel Python programs.

To start a Python debugging session using the Session Editor

  1. Open the Python Session window of the Session Editor using one of the following methods:

    • Select File > Debug a Python Program.

    • On the Start Page, select Debug a Python Program.

    Python Session Editor showing session, interpreter, script, arguments, and program environment fields

  2. Enter a name in the Session Name field.

  3. In Python Details, enter the path to the Python interpreter, or select Browse to locate and select the interpreter.

    The interpreter must be an executable regular file, or a bare name such as python3 that is found on the debugger's PATH. If you enter a relative path, TotalView resolves it from the session's working directory, if one is set.

  4. In Script Details, enter the script file name, or select Browse to locate and select the script.

    The script must be readable, but it does not need to be executable. Its file name must end in .py or .pyw (case-insensitive), or its first line must be a shebang (#!) that identifies Python.

  5. (Optional) Complete one or more of the following to further configure the session:  

  6. Select Load Session.

    The Source view displays the Python wrapper program (tv_python_wrapper.c).

  7. Select Go (Go command icon).

    The Source view displays the Python script.

  8. (Optional) Set any breakpoints you want in the Python code. See Set breakpoints in Python code.

  9. Select Go (Go command icon) to run the Python script.

Previously used interpreters and scripts are available in their respective field histories. The script history is separate from the file name history in other windows of the Session Editor. The editor does not automatically discover installed interpreters, virtual environments, or conda environments.

The Python wrapper program (tv_python_wrapper.c) is internal and is not stored in the saved session. To learn more, see About the TotalView Python wrapper.