Skip to content

How to Debug Your Python Code Properly by Using Visual Studio Community 2023 Python Debugging

FurkanGozukara edited this page Oct 28, 2025 · 1 revision

How to Debug Your Python Code Properly by Using Visual Studio Community 2023 - Python Debugging

How to Debug Your Python Code Properly by Using Visual Studio Community 2023 - Python Debugging

image Hits Patreon BuyMeACoffee Furkan Gözükara Medium Codio Furkan Gözükara Medium

YouTube Channel Furkan Gözükara LinkedIn Udemy Twitter Follow Furkan Gözükara

Code debugging is one of the most fundamental, crucial and important aspects of software development. It is the way to properly construct your software logic and find out the reasons for problems to solve them.

Without proper debugging knowledge, it would be almost impossible to develop a big application. Without debugging, it would be too hard, time-consuming, and resources expensive to build an application and write efficiently working code.

Even my 4th-year students were having trouble debugging their Python code. Therefore, I decided to make this video.

I believe that Microsoft Visual Studio is one of the best IDEs out there. Perhaps the very best one. Also with Community Edition now it is free to use.

So In this video, I show how to do debugging while writing Python code by using Visual Studio Community Edition 2022.

In order to execute code step by step when paused during debugging, use F10 (Step Over). If you want to go inside of function calls during step by step execution, use F11 (Step Into). Both buttons are available under Debug Menu.

If you also have questions please leave a comment and I will try to make a video and cover your question. Please also do subscribe and like the video. Thank you.

Discord channel link of our channel. You can come and ask any questions regarding this video or any other programming related problems : https://discord.gg/6Mrb8MwteQ

How to use Discord : https://discord.gg/rfttctFewW

My name is Furkan Gözükara and I am a PhD computer engineer from Turkey : https://www.linkedin.com/in/furkangozukara/

If you are interested in programming but you lack experience and skills I suggest you to watch our following programming lecture videos. They are complete lectures and totally free.

[1] Introduction to Programming Full Course with C# playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffskoSXySh0MdiayPJsBZ7m2o

[2] Advanced #Programming with C# Full Course Playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffslHaBdS3RUW26RKzSjkl8m4

[3] Object Oriented Programming Full Course with C# playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsnH3XJb66FDIHh1yHwWC26I

[4] Asp.NET Core V5 - MVC Pattern - Bootstrap V5 - Responsive Web #Programming with C# Full Course Playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsnAWtgk4ja3HN3xgMKF7BOE

[5] Artificial Intelligence (AI) and Machine Learning (ML) Full Course with C# Examples playlist: https://www.youtube.com/playlist?list=PL_pbwdIyffskVschrADCL6KEnL_nqDtgD

[6] Software Engineering Full Course playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffslgxMVyXhnHiSn_EWTvx1G-

[7] Security of Information Systems Full Course playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffslM_o92NwkaUzD7C6Fekx26

[8] (Turkish) Bilgisayar Becerileri Tam Ders playlist : https://www.youtube.com/playlist?list=PL_pbwdIyffsmyE2e909ea1MXLcMb8MenG

Video Transcription

  • 00:00:00 Hello everyone, welcome to Software Engineering Courses YouTube channel again.

  • 00:00:07 So today I am going to show you how to do debugging when doing Python programming.

  • 00:00:12 Debugging is one of the most crucial and important things in when doing programming.

  • 00:00:20 So you have to know how to do debugging in any programming language that you are using.

  • 00:00:28 My students were having trouble when doing Python programming, having trouble to do debugging

  • 00:00:34 when doing Python programming.

  • 00:00:36 So I decided to make this video for you.

  • 00:00:42 So for debugging and Python development, I will be using Visual Studio Community Edition

  • 00:00:49 2022.

  • 00:00:51 I think Visual Studio is one of the best, maybe the best, integrated development environment

  • 00:00:58 out there that you can use for programming purposes, for.NET programming, for C# (CSharp) programming

  • 00:01:06 or for Python programming.

  • 00:01:08 So to do that you just need to download Visual Studio and you need to install, let me show

  • 00:01:15 you, the Python development.

  • 00:01:23 Okay the installation has been completed, so I am launching a new window to compose

  • 00:01:29 a new Python project.

  • 00:01:31 I will be using a simple calculator project to demonstrate you how to do debugging when

  • 00:01:41 doing Python programming.

  • 00:01:43 So I am selecting Python application, next, okay it can be anything.

  • 00:01:57 All right let's copy and paste a simple example calculator, okay.

  • 00:02:09 So you see that currently debug mode is selected, this is important and also we have an environment

  • 00:02:16 which is Python 3.7.

  • 00:02:20 You need to add an environment to be able to do debugging and you need to set it as

  • 00:02:26 I said as current environment.

  • 00:02:29 These are the two things that is necessary for you to be able to do debugging.

  • 00:02:36 So for doing debugging you can click the line where you want to debug the software like

  • 00:02:42 this or you can click F9 in your keyboard that will also put a breakpoint for the line

  • 00:02:51 that your cursor is currently located or alternatively you can also come debug and toggle breakpoint

  • 00:03:01 button like this.

  • 00:03:02 So all of these will work and let's make an example like add method, I am putting a breakpoint

  • 00:03:12 here running the application.

  • 00:03:15 So I will select the option one which will get into add method.

  • 00:03:22 Let's enter the first number as 40 and second number as 5.

  • 00:03:27 Okay so you see currently our application is paused at the breakpoint we did put and when we check

  • 00:03:35 the locals we can see the local variables you see X is 40, Y is 5 and do we have any

  • 00:03:44 other special things?

  • 00:03:46 We have function add, divide, multiply, subtract function variables and the other things.

  • 00:03:53 So when I hover my mouse you see I am able to see values there.

  • 00:04:00 This is how you can do debugging.

  • 00:04:02 So I will click continue with F5 or from here and let's say yes one okay okay.

  • 00:04:15 Now it is paused at my other breakpoint which is here you see choice and the value of choice

  • 00:04:22 is 1 and number 1 is 43 which is a double number I believe in the C# (CSharp) but in Python

  • 00:04:35 it could be different and the number 2 is 11 and it will print it on the screen and

  • 00:04:42 it will return the value.

  • 00:04:46 Okay so this is how you can do debugging in Python programming.

  • 00:04:51 This can be look to you as easy but however I have seen many of my students were not able

  • 00:04:59 to do properly debugging in the integrated development environments they are using to

  • 00:05:06 develop Python applications.

  • 00:05:08 This is extremely crucial because when you are developing an application you have to

  • 00:05:13 do it step by step and verify your application is working before you add another feature

  • 00:05:22 function or whatever and when there is an error you have to properly debug it to be

  • 00:05:29 able to see where your error is.

  • 00:05:32 If you can't debug it properly then you will have hard time to find out your problem and

  • 00:05:41 solve it therefore debugging is extremely important for example in this video that is

  • 00:05:53 related to C sharp okay here I had to do full debugging to find out that the application

  • 00:06:03 has memory leak because of the spammed tasks were not getting completed and they were filling

  • 00:06:15 the entire stack.

  • 00:06:18 Okay so the memory of my computer was getting filled over time and the application was becoming

  • 00:06:26 unresponsive and frozen and if I didn't debug properly then I wouldn't know the cause of

  • 00:06:37 the problem okay and let's check another thing I wonder if it is available for Python I think

  • 00:06:47 there is also launch Python profiling okay and start okay reports Python application

  • 00:07:01 okay let's just close it okay I think after I have closed the application yes you see

  • 00:07:11 Visual Studio is even able to show you where your application uses most of your CPU or

  • 00:07:21 other things like where it waits so the Visual Studio I believe the best development software

  • 00:07:32 best software development integrated development environment thank you for watching hopefully

  • 00:07:44 see you later.

Clone this wiki locally