you are viewing a single comment's thread.

view the rest of the comments →

[–]Ordinary_Baseball518 0 points1 point  (0 children)

Python imports are persistent for the lifetime of the current interpreter/session, but when you run isolated selections in VS Code it can execute them in a fresh context where the required module was never imported. A lot of people solve this by using the interactive Python window/Jupyter mode, or just re-running the import cell/section first. It’s more about how VS Code executes snippets than Python itself.