The following debugging capabilities are supported:
More on debugging in Visual Studio Code here.The extension supports debugging of a number of types of python applications. Keep track of your breakpoints in the lower left corner section “Breakpoints”. You can also view the terminal or use the debug console at the bottom. Inspect objects and navigate the call stack to the left and use the navigation in the top center to continue, step over/into/out of, restart or stop. Visual Studio Code’s debugger wrapper will now execute the command and stop the execution on your breakpoints. vscode/launch.json) and execute them (click the green “play” button). Now, in the debug menu, from the “Run and debug” section (upper left corner), you can pick between the different configurations (from the. Set breakpoints and runĪdd breakpoints by clicking just left to the line number of the code you wish to debug. This was only meant to bootstrap the development environment and make the poetry command available in the virtual environment.
the python -m poetry install -vvv command in its debugger. The way this works is that Visual Studio Code will wrap e.g. You can see in the above file that I have added two basic examples of executing Poetry poetry install and poetry update. vscode/launch.json file, so let’s create it: Set up tasks.jsonĭebugging in Visual Studio Code is set up in the project folder’s. venv) as the active Python interpreter for the project. Make sure you have the Python extension and all other necessities for sane Python development. Launch Visual Studio Code and open the poetry project folder, containing all source code. The latter is what we are going to use when debugging! Visual Studio Code setup Now you have the poetry command at your disposal, as well as python -m poetry, provided by the development installation. Moving on…Įven if uses Python 3.9.2, it will still be able to complete an installation in the Python 3.8.8 virtual environment! So I would go either with venv or virtualenv. Python 3.9.2 # here we expected Python 3.8.8! # WARNING: this will NOT work! $ poetry config virtualenvs.in-project true $ install # creates the ".venv" automatically $ source. The versions selected are just used to illustrate that different interpreters can be used for Poetry and the projects themselves. Let’s install Python 3.9.2 for system-wide installed tools and Python 3.8.8 for development/debugging of Poetry. Installation instructions can be found here and pyenv’s prerequisites can be found in their wiki. I like to pick the Python interpreter version for a system-wide installations of tools, but also for individual projects using Pyenv.
In order to get set for debugging, we need to install/setup a couple of tools: My developer environment is Ubuntu 20.04 via WSL2 running on Windows 10, so that’s what this guide is written for.
Debugging Poetry with Visual Studio Code #PythonĪ guide on how to set up debugging of Poetry in Visual Studio Code, using Pipx and Pyenv.