gymopk.blogg.se

How to debug in visual studio code python
How to debug in visual studio code python












how to debug in visual studio code python

To do it, open vscode's debug tool and add a new configuration.

how to debug in visual studio code python

To fix it, the first thing I needed to do was to tell vscode to start running my code as if I was running it from the command line as a module. Therefore, relative imports stop working as well. This debugger mode runs your file as the root and, by doing so, it completely loses information about the modules on the same folder and above. The thing is, I failed to understand that I was using vscode's current file debugger. Now I pretty like it! :) A good post on how import works with python can be found here. Well, at least that's what I thought at that time. What was happening? I didn't know by then, but I got caught on python's " import hell".

how to debug in visual studio code python

What would happen is, I would fix the debugging imports, but only to realize I broke it while trying to run the package from the command line, and vice-versa. I knew I was doing something really wrong. And while I learned a lot on how to import modules from reading some well-known python packages/frameworks ( requests, django, scrapy, flask, and others), I frequently found myself changing the way I imported modules in order to get the debugging tool working properly. The thing is, I wanted my code to be contained within a python package composed of modules to make it reusable elsewhere. But, at the beginning, I was using it the wrong way, completely. I can't stress enough how much I have learned and how my learning process has improved since I learned how to use Visual Studio Code (vscode) debugging capabilities.īeing able to add some new piece of code and press F5 to debug it almost instantaneously was a breeze.














How to debug in visual studio code python