Python Basics: Django in VS Code, fix the error `Unable to import django.db`

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


While working on a Django app in VS Code you might run into a problem. VS Code underlines the from keyword in an import, and if you hover it with the mouse you will see the error Unable to import 'django.db' pylint(import-error) showing up.

This is because VS Code is not running the Virtual Environment of the app.

To fix it, run cmd-shift-p (or click View -> Command Palette and run the command Python: Select Interpreter.

VS Code will show you a list of Python interpreters found.

Choose the one corresponding to your virtual environment, in this case the last option.

The error will disappear.

Lessons in this unit:

0: Introduction
1: Introduction to Python
2: Installing Python 3 on macOS
3: How to check the current Python version
4: Running Python programs
5: Python 2 vs Python 3
6: The basics of working with Python
7: Python Data Types
8: Python Operators
9: ▶︎ Django in VS Code, fix the error `Unable to import django.db`
10: Use a GoPro as a remote webcam using Python