2025, Nov 16 01:00

Django reCAPTCHA ModuleNotFoundError: No module named captcha - fix by setting INSTALLED_APPS to django_recaptcha

Resolve Django reCAPTCHA ModuleNotFoundError: No module named captcha. Set INSTALLED_APPS to 'django_recaptcha' instead of 'captcha' to stop startup crashes.

Integrating Google reCAPTCHA into a Django form can fail at the very first step: server startup. A typical symptom is a long traceback that ends with ModuleNotFoundError: No module named 'captcha', even though django-recaptcha was installed and the form imports look correct. The issue is not about keys or templates; it’s about the app name Django tries to import.

Minimal failing setup

The configuration below looks reasonable at first glance. The package django-recaptcha is installed, the form imports are from django_recaptcha, and the app list contains what appears to be the captcha app:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'support',
    'captcha',
]
from django import forms
from django_recaptcha.fields import ReCaptchaField
from django_recaptcha.widgets import ReCaptchaV2Checkbox

class SupportForm(forms.Form):
    user_email = forms.EmailField()
    message_text = forms.CharField(widget=forms.Textarea)
    spam_check = ReCaptchaField(widget=ReCaptchaV2Checkbox)

Despite the correct imports in the form, runserver crashes during app registry population with ModuleNotFoundError: No module named 'captcha'.

What actually goes wrong

Django loads each entry from INSTALLED_APPS by importing it. When it hits 'captcha', it tries import_module('captcha') and fails, because the installed module name is not captcha. The installed package is django-recaptcha, and its importable app is django_recaptcha. This mismatch between the INSTALLED_APPS entry and the actual module name is the sole cause of the error.

“app name should be django_recaptcha as per instructions”

The fix

Point INSTALLED_APPS at the real module name. Nothing else in the provided setup needs to change.

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'support',
    'django_recaptcha',
]

The form code that imports from django_recaptcha is already consistent, so it can remain as-is:

from django import forms
from django_recaptcha.fields import ReCaptchaField
from django_recaptcha.widgets import ReCaptchaV2Checkbox

class SupportForm(forms.Form):
    user_email = forms.EmailField()
    message_text = forms.CharField(widget=forms.Textarea)
    spam_check = ReCaptchaField(widget=ReCaptchaV2Checkbox)

Why this matters

In Django, three names often get conflated but are not the same: the pip package name, the Python import path, and the Django app label in INSTALLED_APPS. django-recaptcha is the package you install; django_recaptcha is the module Django must import at startup; and using a different word like captcha makes Django import the wrong thing and fail immediately. Reading the last line of the traceback usually reveals precisely which name Django could not import.

Conclusion

When a freshly installed integration crashes on startup with ModuleNotFoundError, compare the INSTALLED_APPS entry with the actual module path shown in the working imports. For django-recaptcha, the correct app entry is django_recaptcha. Aligning these names resolves the error and lets the server boot so you can proceed with form validation and reCAPTCHA checks.