I used poetry to create a .venv folder in my project. If I use poetry shell
to open a shell in the virtual environment and run my code with python main.py
everything works as intended.
I used the "select environment" command to make sure VSCode uses that environment and it shows up correctly in the bottom right as 3.11.0 ('.venv': poetry)
and it works in so far that the editor recognizes my installed modules when autocompleting.
However when I right-click run main.py
I get an Error that a module is not installed even though, as mentioned previously, it works fine when I run it from a shell in the virtual environment.
Is there some additional bit of configuration I'm missing so that "Run" will actually execute inside the venv?
Please use Run Python File or Debug Python File choices, which are provided by the official Python extension, instead of Run Code, which is provided by another extension (probably Code Runner). This is displayed in the upper right corner of the editor.