+++
title = "Debug"
weight = 60
+++

## Using gdb

If a BornAgain Python script crashes, re-run under gdb.

To debug a Python script, run
```bash
gdb --args /usr/bin/python3 <script>
```
where the path `/usr/bin/python3` must be adapted to point
to a Python executable that is not installed via pyenv.
Also consider `python3-dbg` (from Debian package of same name).

If Python is installed via Pyenv, then the command `python`
typically refers to a wrapper script `<pyenv_path>/shims/python`.
In this case, run
 ```bash
gdb -ex r --args bash python <script>
```
or
 ```bash
gdb `pyenv which python`
```
