You don't need to keep moving a statement one line at a time until you figure out where the error is, the error message (stack trace) tells you exactly where it is. I would definitely spend a bit of time familiarising yourself with the output of a stack trace because it can be a very useful debugging tool.
But maybe you can change your code a little bit to make this easier to work with. Assuming you are not creating a class to contain your code you could do the following:
def main():
Put your code in here
if __name__ == "__main__":
main()
input('Press Enter to Exit...')
This gives you an exit prompt before your program exits whether it errors or not.
But to fix the whole issue of the window flashing up and disappearing, run your script from a terminal, i.e. the command prompt or inside an editor, directly. This way the window does not close once the script finishes running and you get to retain the output for later review.