there isn't a single piece of code that I ever put together that worked longer than a few years out of the box without some breaking change
The best practice, which prevents this issue, is to use envs, (as well as pinning your dependencies for any given project in a committable artifact).
(Seems like a lot of people are using system Python, which isn't really recommended.)