Spyder tutorial #782
OverLordGoldDragon
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Why?
Major convenience and efficiency over non-IDE alternatives
Install
Anaconda. Open "Anaconda Powershell Prompt", run
or if already have Anaconda,
Anaconda automates dependency and conflict handling and I recommend it, but can do without. Some of this tutorial assumes Anaconda install.
Run
from Anaconda Powershell Prompt. I don't recommend using the Anaconda Navigator (very slow).
Quick tips
as a former MATLAB user, I've always kept color of comments the same
My layout is like this, editor on left and console + other stuff on right, with toolkit hidden:
Debugging / Basic use
Running cells
Make cells with
#%%
, run withCtrl + Enter
orShift + Enter
to advance to next cellcell_demo0.mp4
Basic debug
Error -> click anywhere in stack trace to go to it -> put breakpoint on that line (
F12
) -> run in debug mode (Ctrl + F5
) -> print some relevant attributesdebug0.mp4
Post-mortem
Ctrl + F6
to bring up run config -> enable "Directly enter debugging when errors appear" -> Run (F5
)debug1-ctrl-f6.mp4
Arbitrary level in stack trace
Exceptions aren't always thrown at source of interest. They may also error only after 50th execution of same line, so breakpoints aren't appropriate.
debug2.mp4
Conditional breakpoint
For debugging loops with known variable values, can do
if a == 1 and b == 2: # breakpoint
, as exception may be thrown long after lines of interestdebug3_iter.mp4
Beta Was this translation helpful? Give feedback.
All reactions