I have a pet project game written in Python which uses blessed
to draw graphics to a Windows command prompt terminal window.
To help develop this, I'd like to be able to make use of the debugging features of an IDE with breakpoints, step-into etc. However, this isn't super straightforward as the graphics do not behave well when the script is executed in the built-in terminal of an IDE (I've specifically tried Thonny and VSCode).
I'm trying to take the following alternative approach with VSCode:
python game.py
python game.py
What I expect to happen:
What actually happens:
Unable to find python module.
is printed at the current cursor locationTimed out waiting for debug server to connect.
Here is the launch.json debugging configuration created by VSCode:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Attach using Process Id",
"type": "python",
"request": "attach",
"processId": "${command:pickProcess}",
"justMyCode": true
}
]
}
Python version 3.11.3
Description of virtual environment installed packages using output from pipenv graph
:
blessed==1.20.0
- jinxed [required: >=1.1.0, installed: 1.2.0]
- ansicon [required: Any, installed: 1.89.0]
- six [required: >=1.9.0, installed: 1.16.0]
- wcwidth [required: >=0.1.4, installed: 0.2.8]
opencv-python==4.8.1.78
- numpy [required: >=1.17.0, installed: 1.26.1]
- numpy [required: >=1.17.3, installed: 1.26.1]
- numpy [required: >=1.23.5, installed: 1.26.1]
- numpy [required: >=1.21.2, installed: 1.26.1]
- numpy [required: >=1.19.3, installed: 1.26.1]
If anyone has a similar issue, I was able to achieve the desired outcome by using a different configuration:
{
"name": "Python: Current File (External Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
}
With this configuration, I can simply click start debugging in VSCode and it will open a fresh external Windows command prompt for me running the game, with debugging in VSCode!