ModuleNotFoundError: No module named 'rest_framework_simplejwt'. I have tried the methods listed in other posts

I am building an authentication system with the JWT token. I have done pip install djangorestframework-simplejwt and pip install --upgrade djangorestframework-simplejwt in my virtual environment. This is my installed-apps in settings.py:

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'rest_framework_simplejwt',
    'rest_framework_simplejwt.token_blacklist',
]

And here is my urls.py:

from django.contrib import admin
from django.urls import path, include
from api.views import CreateUserView 
from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView 

urlpatterns = [
    path("admin/", admin.site.urls),
    path("api/user/register",CreateUserView.as_view(), name="register"),
    path("api/token/",TokenObtainPairView().as_view(),name="get_token"),
    path("api/token/refresh/",TokenRefreshView.as_view(),name="refresh"),
    path("api-auth/", include("rest_framework.urls"))
]

I have these on my pip list:

django-rest-framework         0.1.0
djangorestframework           3.16.0
djangorestframework-jwt       1.11.0
djangorestframework_simplejwt 5.5.0
pip                           25.1.1
PyJWT                         1.7.1
python-dotenv                 1.1.0
pytz                          2025.2
rest-framework-simplejwt      0.0.2

But when I run the code, it still says ModuleNotFoundError: No module named 'rest_framework_simplejwt'. I have checked the documentation and other posts. Is there anything else I am missing?

Django doesn't seem to be installed in your environment. Please confirm if your pip list is complete, if not, run:

pip install django 

Also, you might be missing a configuration in settings.py. According to the docs, your django project must be configured to use this library. In settings.py, add rest_framework_simplejwt.authentication.JWTAuthentication to the list of authentication classes:

REST_FRAMEWORK = {
    ...
    'DEFAULT_AUTHENTICATION_CLASSES': (
        ...
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    )
    ...
}

Also you seem to have some packages with similar names installed in your environment and looking at them, some are either not maintained or are lacking a proper description. It is not clear to me why you have those packages so if you are mistaking them for the real package (i.e. djangorestframework-simplejwt), you might want to get rid of them except if they're useful to you in some way.

Вернуться на верх