Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module import errors with Virtual Environments and VSCode

I have created a virtual environment to install some Python modules. I am using mini-conda to manage and activate the environments.

One issue that I am facing is that the code runs fine when I run it through the terminal with the virtual environment activated.

However, the same code does not run when I use the "Run Code" button (Ctrl + Alt + N) in VSCode. It gives me Module Not Found Error.

How can I run the code from VSCode in the context of my virtual environment?

like image 494
Real Noob Avatar asked Jan 28 '26 16:01

Real Noob


1 Answers

You should use the same interpreter in VSCode; To do this you should use Python: Select Interpreter option; CTRL+Shift+p(default key-bindings) and search for Python: Select Interpreter or search for it in the VSCode settings.

like image 170
laurbtzt Avatar answered Jan 30 '26 05:01

laurbtzt