Python Debugging (PyCharm + VS Code)

แชร์
ฝัง
  • เผยแพร่เมื่อ 6 ส.ค. 2024
  • Step by step through your program.
    Debugging is an essential and unavoidable part of programming. Everyone writes bugs, and we'd like to get rid of them. Print statements are fine to a certain point, but live debugging is usually a better option. With live debugging, you can step through your program one statement at a time, and set breakpoints at interesting places to stop, view, and interact with the state of the program before it proceeds. This is a very beginner-friendly tutorial on how to use PyCharm and VS Code for live debugging in Python.
    CONTEST CURRENTLY CLOSED! The winners have been contacted.
    OFFICIAL CONTEST RULES:
    1. All entries must comply with the TH-cam community guidelines ( th-cam.com/users/tcommunity_gu...) and TH-cam Terms of Service (th-cam.com/users/static?gl=US&t.... Entries that violate TH-cam guidelines are automatically disqualified.
    2. TH-cam is not a sponsor of the contest and viewers are required to release TH-cam from any liability related to the contest.
    3. Privacy notice: no personal data will be collected for this contest.
    4. In order to enter, you must (a) be one of my subscribers, AND (b) make a top-level comment to the video including #mcoding somewhere in the comment.
    5. The contest is free, there is no fee required to enter.
    6. Winners will be chosen randomly 1 week after the date the video went live from all users who have entered and not been disqualified.
    7. Each winner will be notified via a comment reply from me that details what prize was won (e.g. "Congratulations! You have won XYZ. Please email me."). I will ask the winner to contact me by email, and I will reply through email with a random token which must be posted as another reply to the winning comment from the winning account in order to verify account ownership and prevent fraud.
    8. Each winner will have 72 hours to respond AND prove account ownership or their prize is automatically forfeited and another winner will be chosen.
    9. A winner can only win 1 prize per contest.
    10. The prize pool for this contest is: 2 licenses ("Free 1-Year Personal Subscription") to any of these JetBrains IDEs: AppCode, CLion, DataGrip, DataSpell, GoLand, IntelliJ IDEA Ultimate, PhpStorm, PyCharm, ReSharper, ReSharper C++, Rider, RubyMine, WebStorm, or dotUltimate. A prize consists of 1 license, which will be delivered in the form of a redeemable code that can be redeemed at www.jetbrains.com/store/redeem/ before March 17, 2024.
    11. You may not enter the contest if doing so would be a violation of any relevant federal, state, and local laws, rules, and regulations, including U.S. sanctions.
    ― mCoding with James Murphy (mcoding.io)
    Source code: github.com/mCodingLLC/VideosS...
    SUPPORT ME ⭐
    ---------------------------------------------------
    Sign up on Patreon to get your donor role and early access to videos!
    / mcoding
    Feeling generous but don't have a Patreon? Donate via PayPal! (No sign up needed.)
    www.paypal.com/donate/?hosted...
    Want to donate crypto? Check out the rest of my supported donations on my website!
    mcoding.io/donate
    Top patrons and donors: Laura M, Dragos C, Jameson, Neel R, Jameson, Pi, Matt R, Vahnekie Johan A, Mark M, Mutual Information
    BE ACTIVE IN MY COMMUNITY 😄
    ---------------------------------------------------
    Discord: / discord
    Github: github.com/mCodingLLC/
    Reddit: / mcoding
    Facebook: / james.mcoding
    CHAPTERS
    ---------------------------------------------------
    0:00 Intro
    1:28 Grocery app
    3:56 Debugging in PyCharm
    12:23 Conditional breakpoints
    16:09 Debugging in VS Code
    21:49 A useful tip... TESTING
    23:38 Outro
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 241

  • @xelaxander
    @xelaxander 5 หลายเดือนก่อน +117

    What separates mcoding from the rest of the Python TH-camr crowd is the fact that even before watching the video, I know my time won’t be wasted. Love your work, hope you consulting company is doing well.

    • @_jaime.
      @_jaime. 5 หลายเดือนก่อน +10

      Totally agree, I feel like he's the only Python youtuber who's able to teach me something new on every single video

    • @jeroenvermunt3372
      @jeroenvermunt3372 5 หลายเดือนก่อน +1

      I am just replying to reinstate your comment, I couldn't agree more. He also is the only one who dives deep into 'boring' subjects, but which are essential for developers. For example this video, but also logging, packaging and testing.

  • @DominicCarrier
    @DominicCarrier 5 หลายเดือนก่อน +25

    As an entirely self-taught software developer, I can attest that these kind of introductory videos are always great. It never assumes "well known knowledge". #mcoding is a very nice resource for all skill levels.
    Love the channel.

  • @LastTigerEyes
    @LastTigerEyes 5 หลายเดือนก่อน +17

    I am always impressed how I still learn things from your videos, even on topics I'm familiar with already (TIL about conditional breakpoints).

  • @olo90
    @olo90 5 หลายเดือนก่อน +21

    Finally a video on debugging for Python. Haven't even watched it yet but I've got big hopes that this will be the video I'll send to every new intern & junior in our team at work 😀

  • @drBnpD
    @drBnpD 5 หลายเดือนก่อน

    Whoa! Another gem from #mcoding! 🌟 Clear, conceptual, and oh-so-needed. Keep 'em coming! 🚀

  • @adamfarquhar1279
    @adamfarquhar1279 5 หลายเดือนก่อน

    I've found setting up the debugging in VS Code to be surprising. Now I know it's not just me! Thanks for the clear explanations and work-arounds for the quirks in the PyCharm and VS Code debugger settings.

  • @Schlynn
    @Schlynn 5 หลายเดือนก่อน

    Really been enjoying your videos alot more recently as I've been diving deeping into Python. Thank you for the upload.

  • @josephpierce8926
    @josephpierce8926 5 หลายเดือนก่อน

    Wanted to say thanks. I didn't know any of this, and it seems super useful. Bonus tip for anyone who has to run their code from the command line, you can add the call breakpoint() in your source file and then use the debugger from the terminal

  • @subswithnovideos-zk2ls
    @subswithnovideos-zk2ls 5 หลายเดือนก่อน

    your videos are actually so helpful in my Python coding journey

  • @seb2721
    @seb2721 5 หลายเดือนก่อน

    Wow super helpful video! I've used the debugger for a while but seeing your methodology to it was insightful.
    I would have changed the data in the file rather than the function, but you don't always have that luxury.

  • @powrusr
    @powrusr 5 หลายเดือนก่อน +1

    Since you recommend testing, I'd love to see more content on testing the hard stuff like API's, files, databases with pytest. Testing static code is easy the IO stuff is more complicated. Thanks for the nuggets! 💪

  • @jeffglass5196
    @jeffglass5196 5 หลายเดือนก่อน

    Genuinely, I applied some new things I learned from this video within half an hour. Thank you for all you do. #mcoding

  • @DanielLavedoniodeLima_DLL
    @DanielLavedoniodeLima_DLL 5 หลายเดือนก่อน +1

    Using the debugger is something that I've procrastinated learning since I began programming in university 10 years ago. Nice to see such a comprehensive video about that topic #mcoding

  • @ilyagrant
    @ilyagrant 5 หลายเดือนก่อน

    Again and again you manage to talk about things that I dealt with but never knew how they should be applied. Thanks for your content!
    #mcoding

  • @AFurreh
    @AFurreh 5 หลายเดือนก่อน

    Genuinely had no idea about conditional breakpoints. Big time saver! #mcoding thank you much for going in to this topic!

  • @justingerber9531
    @justingerber9531 5 หลายเดือนก่อน

    Awesome video as usual! I never knew about conditional break points, seems super useful, I’ll have to try them out! Also I’ve been learning and implementing testing lately. It’s hard to write good tests, but once tests are written it is such a joy to refactor and improve code knowing you have your tests as a sort of safety net. Thanks for the video #mcoding!

  • @user-bp6eh7en1v
    @user-bp6eh7en1v 5 หลายเดือนก่อน +8

    13:47 really nice to see him laugh at something goofy like this 😄 #mcoding

  • @goost0852
    @goost0852 5 หลายเดือนก่อน +9

    More basic than the usual, but still a nice refresher :)

  • @nlioc4
    @nlioc4 5 หลายเดือนก่อน

    I swear every time I think about wanting to learn something, #mcoding posts a video about it the next day

  • @loic1665
    @loic1665 4 หลายเดือนก่อน

    Great video ! Love the last advice about unit testing! I've personally had to debug asyncio app and it's really hard!

  • @jasperkousen5470
    @jasperkousen5470 5 หลายเดือนก่อน +1

    Thanks for all the great content!

  • @SyberiaK
    @SyberiaK 5 หลายเดือนก่อน

    As a professional print debugger user, I'm absolutely amazed that these live debuggers exist :D
    You did a great job explaining them #mcoding

  • @mojo9Y7OsXKT
    @mojo9Y7OsXKT 5 หลายเดือนก่อน

    As far as a beginner live debug tutorial is concerned #mcoding has done an excellent job in this vid. I am a seasoned quant programmer and tend to often develop code in live debugging mode. With interpreted languages like python and matlab this is not as important, but with something like C/C++ its very handy.

  • @Phaust94
    @Phaust94 5 หลายเดือนก่อน +1

    #mcoding
    Man, 6 years into Python development and never knew about conditional breakpoints in PyCharm. Sweet!

  • @Acuzzio
    @Acuzzio 5 หลายเดือนก่อน

    What an excellent video. Thanks a lot.

  • @BartDorlandt
    @BartDorlandt 5 หลายเดือนก่อน

    Thank you for yet another great video. Quite nice you showed both vscode and pycharm!
    #mcoding

  • @MattiasBrunschen
    @MattiasBrunschen 5 หลายเดือนก่อน

    Just started to use vscode, so your hints are very helpful. Thank you, #mcoding .

  • @stevengorlich4993
    @stevengorlich4993 5 หลายเดือนก่อน

    #mcoding after 10 years with python, I still learn new stuff with your videos. I pushed my C-board to give us professional pycharm licences, wished I had a personal one as well :)

  • @levatius4397
    @levatius4397 5 หลายเดือนก่อน +1

    I am always surprised how many people don’t know about live debugging, also big PyCharm fan 🎉 #mcoding

  • @everorlandoreyesruiz9789
    @everorlandoreyesruiz9789 5 หลายเดือนก่อน

    Awesome vid, thanks 👍

  • @kitschlab
    @kitschlab 5 หลายเดือนก่อน

    Thank you #mcoding for this!
    I can't believe I never used the python debugger. Can't wait to try it out.

  • @replicaacliper
    @replicaacliper 4 หลายเดือนก่อน

    Super useful to people who aren't from a cs background, as a physicist i use Python all the time but I've never learned how to debug, I just place print statements everywhere haha

  • @richwiss
    @richwiss 5 หลายเดือนก่อน

    Hey! Thanks for the videos (as always). Been a long time vscode user but would be super happy to try pycharm! #mcoding

  • @redbeangreenbean
    @redbeangreenbean 5 หลายเดือนก่อน

    This was immensely helpful. Thanks #mcoding!

  • @cyberduck4923
    @cyberduck4923 5 หลายเดือนก่อน

    Another great video from the best-produced Python channel on TH-cam!
    #mcoding

  • @moejo8187
    @moejo8187 5 หลายเดือนก่อน

    I didn't know the conditional breakpoints. Thanks for the explanation.
    #mcoding

  • @NicolasJoye
    @NicolasJoye 5 หลายเดือนก่อน

    Thanks, Jetbrains, for providing the licenses!!!

  • @ellipsiss
    @ellipsiss 5 หลายเดือนก่อน

    Great work #mcoding
    Big time fan!

  • @shabik3
    @shabik3 5 หลายเดือนก่อน

    Noice, this is a holy grail of python vids!! :D

  • @TheMathman7
    @TheMathman7 5 หลายเดือนก่อน +1

    Breaking on uncaught exceptions is very handy as well!

  • @maciejbrzeski9740
    @maciejbrzeski9740 5 หลายเดือนก่อน

    Wonderul video as always. I learn a lot new things every time. Thanks for all your effort that you put in those videos! #mcoding

  • @FrancisCharetteMigneault
    @FrancisCharetteMigneault 5 หลายเดือนก่อน +1

    Thanks for the info about PyCharm's setting for Python 3.12 debugging. That will be useful in a near future for sure! #mcoding

    • @RoysIdea
      @RoysIdea 3 หลายเดือนก่อน

      Alas I can’t place a comment in the main thread, so hope someone or #mcoding is able to answer how to debug when starting from the command line with arguments. Otherwise I’m forced to use the print statements

  • @danielschmider5069
    @danielschmider5069 3 หลายเดือนก่อน

    good video, you'd be surprised how many people never learned to properly debug and just use print debugging.
    Nothing against print debugging if it gets the job done, but in my experience it takes more trial and error because you have to know what to print first - while debugging gives you the chance to inspect all variables during runtime and see them go through different states and values. You end up finding the problem so much quicker, and never have to delete your print statements after you're done debugging.
    thank you #mcoding

  • @gregkeith9521
    @gregkeith9521 5 หลายเดือนก่อน

    Reminds me of VBA debugging. Very good explanation #mcoding

  • @moonskined
    @moonskined 5 หลายเดือนก่อน

    I recently started learning python so this was very helpful. Thank you. #mcoding

  • @cristianbitica8204
    @cristianbitica8204 5 หลายเดือนก่อน

    I'm surprised of how much I can learn from these videos. #mcoding

  • @ChristopherFerguson
    @ChristopherFerguson 5 หลายเดือนก่อน

    I always find your videos so helpful. Thanks so much! #mcoding

  • @ginggung2413
    @ginggung2413 5 หลายเดือนก่อน

    very nice job highlighting the usefulness and ease of use. Course I'd also love a piece xD #mcoding

  • @hargrav3s740
    @hargrav3s740 5 หลายเดือนก่อน

    Love a nice debugging session breakdown, when I joined the industry, live debuggers truly are king! (That and good logs) #mcoding

  • @Seun_O
    @Seun_O 5 หลายเดือนก่อน

    I learned something new. Thanks for the high quality content #mcoding

  • @Yehonathanatos
    @Yehonathanatos 5 หลายเดือนก่อน

    Thank you very muchly!!

  • @timothyhumphreys1231
    @timothyhumphreys1231 5 หลายเดือนก่อน

    As a professional print debugger myself I found this video super helpful! #mcoding

  • @NikitaSerditov
    @NikitaSerditov 5 หลายเดือนก่อน

    #mcoding is a truely useful Python programming channel. Thanks a lot.

  • @Articha
    @Articha 5 หลายเดือนก่อน

    Sometimes info from videos shock me. Keep going, James! #mCoding

  • @rukopet
    @rukopet 5 หลายเดือนก่อน

    Thank for your videos man!!!!
    #mcoding

  • @tooru
    @tooru 5 หลายเดือนก่อน

    Of course I want a license too #mcoding but still thank you for producing such useful and polished content. We can see that you care about making it better.

  • @adrianfletcher8963
    @adrianfletcher8963 5 หลายเดือนก่อน +3

    I finally ripped the bandaid and used the debugger for the first time 😅. I was like wow all these print statements are so useless. I'm glad mCoding is scratching the itch further. He said to debug in his python nooby video, but it still doesn't mean that we got that full tutorial #mcoding

    • @Ignisami
      @Ignisami 5 หลายเดือนก่อน +1

      Print statement debugging is never *entirely* useless. Code can behave differently when you're in the debugger. To give but one reason: Each step of the code takes longer (because you're reading what the debugger says, for one), things have all the time in the world to resolve before moving on. When you actually run the code normally that may not always be the case.

    • @adrianfletcher8963
      @adrianfletcher8963 5 หลายเดือนก่อน

      @@Ignisami That's true. I think I'm still getting used to the capability and am having "everything is a nail" syndrome at the moment t

  • @talshafir10
    @talshafir10 5 หลายเดือนก่อน

    I love #mcoding videos!

  • @Ayor88
    @Ayor88 5 หลายเดือนก่อน

    your videos are gold for self learner ! #mcoding

  • @archibald-yc5le
    @archibald-yc5le 5 หลายเดือนก่อน

    Great debugging guide, thank you #mcoding

  • @CaptainCsaba
    @CaptainCsaba 5 หลายเดือนก่อน

    I love your videos, #mcoding !

  • @aliwelchoo
    @aliwelchoo 5 หลายเดือนก่อน

    Conditional breakpoints is a big new one for me. Will be using that! Only thing I don't understand is why your pycharm debugger doesn't drop straight into a breakpoint upon exception?

  • @drBnpD
    @drBnpD 5 หลายเดือนก่อน

    Super helpful! Thanks #mcoding

  • @pipurs
    @pipurs 5 หลายเดือนก่อน

    I can safely say that the debugger, any debugger as a matter of fact, has been my best tutor. Not only regarding my own code, or my college's code, but also down there in the nitty gritty of things. But then I'm a 100% autodidact - which means that I've stared at some amount of exceptions through my years...
    Debuggers ftw.

  • @Excgo
    @Excgo 5 หลายเดือนก่อน

    @mCoding The code you have given in the git repo is the already fixed version. Is that by decision or should the buggy version be in the repo?

  • @kall2075
    @kall2075 5 หลายเดือนก่อน

    #mcoding need more videos like this. Preferably on more complex code base where the issue is on the import code

  • @meepmeep6363
    @meepmeep6363 5 หลายเดือนก่อน

    Really great video, thanks! #mcoding

  • @mattjax16
    @mattjax16 5 หลายเดือนก่อน +2

    Jetbrains debugger is why I fell in love with jetbrains products in the first place vs code can’t compare lol

    • @mattjax16
      @mattjax16 5 หลายเดือนก่อน

      Well I’m sure it can but I don’t feel like learning until now lol

  • @failgun
    @failgun 5 หลายเดือนก่อน

    This is the main problem I had with my university's Python course, we did 12 weeks of it, and they introduced lots of concepts - variables, strings, types, functions, classes, etc. It wasn't bad for an intro-to-programming course taught with Python. But they didn't mention how to use our IDE's debugging tools _once_ . I found out about it later and I was baffled that they willingly let us believe there was no better alternative than littering our code with print statements (this was even encouraged) to figure out what was going on.

  • @jayp2570
    @jayp2570 4 หลายเดือนก่อน

    Yes I love pycharm too!

  • @craigmcconomy9346
    @craigmcconomy9346 5 หลายเดือนก่อน

    I love your videos! Always recommend to my coworkers. #mcoding

    • @craigmcconomy9346
      @craigmcconomy9346 5 หลายเดือนก่อน

      one cool trick I saw recently was (ab)using conditional breakpoints to introduce transient print side effects, eg. a condition of "print(f'{user} logged in') and False"

  • @mishaga
    @mishaga 5 หลายเดือนก่อน

    hey! this is nice one! thank you for your content :) #mcoding

  • @Mayur7Garg
    @Mayur7Garg 5 หลายเดือนก่อน

    Conditional breakpoints in VSCode also allows for hit counts and triggered breakpoints instead of expressions. Hit count based breakpoints are good for loops and triggered breakpoints are good when you want to break only when a previous breakpoint was hit. #mcoding

  • @Landee
    @Landee 5 หลายเดือนก่อน +1

    Need more beginner tips !! #mcoding

  • @fluffykitties9020
    @fluffykitties9020 5 หลายเดือนก่อน

    very interesting, printing can become unbearable. this is also a great way to learn coding. i'm a vscode user but wouldn't mind trying pycharm.

  • @merlinpritlove5585
    @merlinpritlove5585 5 หลายเดือนก่อน

    Love your videos! #mcoding

  • @jeevan1016
    @jeevan1016 5 หลายเดือนก่อน

    What is the efficient way to debug a function that is used in threading?
    Please give us some insights on this topic.

  • @sonosus
    @sonosus 5 หลายเดือนก่อน

    Great video as always. #mcoding

  • @mishaed-pm3xx
    @mishaed-pm3xx 5 หลายเดือนก่อน

    clear as mud 😅👍

  • @PedroSerra1982
    @PedroSerra1982 5 หลายเดือนก่อน

    Great work #mcoding

  • @jesusromero9167
    @jesusromero9167 4 หลายเดือนก่อน

    This is gold! It would be amazing if you make a series of how to use pycharm the way is intended #mcoding

  • @seppevansteenbergen1628
    @seppevansteenbergen1628 5 หลายเดือนก่อน

    Nice tutorial! #mcoding

  • @plato4ek
    @plato4ek 5 หลายเดือนก่อน

    Woo-hoo! Another contest! #mcoding

  • @Talon_24
    @Talon_24 5 หลายเดือนก่อน

    Those are some good examples, esp helpful when forwarding to friends who just started learning :) #mcoding

    • @mCoding
      @mCoding  5 หลายเดือนก่อน

      Yes please forward to many friends :). Also, you WIN! You get a license, please contact me via email to claim.

    • @Talon_24
      @Talon_24 5 หลายเดือนก่อน

      @@mCoding Thanks so much! The number is 199

  • @BrandonSolo
    @BrandonSolo 5 หลายเดือนก่อน

    I'#mcoding and debugging so much better thanks to this channel (padum tsssss)

  • @PedigreeGuitars
    @PedigreeGuitars 5 หลายเดือนก่อน

    Thanks for all the great learning #mcoding

  • @Th3Vitamine
    @Th3Vitamine 5 หลายเดือนก่อน

    Next logical step to cover would be remote debugging, and maybe some cli variants, like pudb. Also a neat feature is python cells in VSCode (denoted by #%%) #mcoding

  • @alexlombardi1790
    @alexlombardi1790 5 หลายเดือนก่อน

    Thanks for the videos! #mcoding

  • @igorb2216
    @igorb2216 5 หลายเดือนก่อน

    PyCharm licence you just said? I'm all in! #mcoding

  • @archiemarqx
    @archiemarqx 5 หลายเดือนก่อน

    I use python for Data Science, so in this case I use both, VS Code for coding in Jupyter Notebbok and PyCharm for Python, and this combination works like a charm to me #mcoding

  • @robotnaoborot
    @robotnaoborot 5 หลายเดือนก่อน

    you can put import pdb;pdb.set_trace() in your code to debug it without using editor. I think it's at least worth mentioning

  • @KarstenFlemming
    @KarstenFlemming 5 หลายเดือนก่อน

    thank you for this video!
    #mcoding

  • @asserhalim2640
    @asserhalim2640 5 หลายเดือนก่อน

    Great video! #mcoding

  • @hiplazma
    @hiplazma 5 หลายเดือนก่อน

    I just started learning python in this video was very useful #mCoding

  • @potzko2552
    @potzko2552 5 หลายเดือนก่อน +1

    tbh I find that the breakpoint() function is a bit of the best from both worlds of a live debugger and print debugging
    I usually put it behind an if :)
    #mcoding

  • @ravipratapmishra7013
    @ravipratapmishra7013 5 หลายเดือนก่อน

    #mcoding only doing to get pycharm, btw video is as it always is, great, thanks for it.

  • @marekmdpdesign
    @marekmdpdesign 5 หลายเดือนก่อน

    Nice, learned few new things when it comes to debugging :) - btw what does mean in your test code for e.g.: „actual = load_recipes(…)” - the three dots as arguments?
    #mcoding

    • @vytah
      @vytah 5 หลายเดือนก่อน +1

      ... is the ellipsis literal. It's an object of type EllipsisType, similar to how 1 is an object of type int

  • @dataplatter
    @dataplatter 5 หลายเดือนก่อน

    What about testing code that might not get run in normal circumstances?
    Also, is there a way to step back in program state? #mcoding

  • @miksa94
    @miksa94 5 หลายเดือนก่อน

    great video! #mcoding

  • @thegothaur
    @thegothaur 5 หลายเดือนก่อน

    Nice video. I noticed that, for some reason I don't understand, Pycharm debugger doesn't work if code is async and I have to use pdb :(