Debugging is a big deal?

Mr. mosh used to debug " debugger " which is not excited in my version of vs studio … instead, there is a " debug and run " and it’s not working in the same way
any clue how to deal with this ??
thanks for helping

Debuggers are useful tools for helping to understand what is happening with your code when it does not work the way you expected.

Usually they work by setting a “breakpoint” and then the code will execute up to the breakpoint and then you can examine variables and step through the code executing one statement at a time.

Without a debugger, you would need a ton of print statements to get the same level of information and it can be really tricky to know when something you logged was triggered.

It may be worth looking up a tutorial on how to use the debugger built into your IDE. For example, this one: Python in VSCode: Running and Debugging • Python Land Tutorial

1 Like

Ok, I wasted a fair bunch of hours trying to make it work with the way that the django videos suggests but it didn’t work for me. that included fiddling with the launch.json in so many different ways, running as admin, re installing vs code.

My best guess is that the vscode project debugger is not picking up either the env or the interpreter correctly. Tried explicitly stating those in the launch.json and didn’t work either.

My solution

When starting the project don’t use pipenv in the way recommended. I’m assuming there must be a way to create your env using pipenv within your project folder but that’s beyond me.

  1. When starting your project folder in vscode, create a virtual environment using .venv by typing type ctrl+shift+p and select Python:Create environment
  2. Select venv, then it will prompt you to select the desired pytho version
  3. do ctrl+shift+p again and select python:select interpreter
  4. This should create a bunch of env files making you env ready to use
  5. install pip install django using the terminal which should already have your new env

Then you should be able to use pip instead of pipenv to install everything in your venv and also the debugger should run swiiftly as it does in the tutorial

Reference: Using Python Environments in Visual Studio Code