Import could not be resolved/could not be resolved from source Pylance in VS Code using Python 3.9.2 on Windows 10

  1. Open the Command Palette (Ctrl+Shift+P), then select the Python: Select Interpreter. From the list, select the virtual environment in your project folder that starts with .env.

  2. Run Terminal: Create New Integrated Terminal (Ctrl+Shift+` or from the Command Palette), which creates a terminal and automatically activates the virtual environment by running its activation script.

  3. Install sqlalchemy and mongoengine with command pip install. Once installing them successfully, there will intellisense when you import them and no warnings shown.

screenshot install package with pip within environment

Besides, the folder .vscode is to store Workspace settings as well as debugging and task configurations.

Leave a Comment