'Unable To Install Simple JWT in my Django Project

Here's my setup right now:

Pip Freeze:

asgiref==3.3.1
Django==3.0
djangorestframework==3.10.0
djangorestframework-simplejwt==4.6.0
PyJWT==2.0.1
pytz==2021.1
sqlparse==0.4.1

Settings.py

from pathlib import Path

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'snippets.apps.SnippetsConfig',
]


REST_FRAMEWORK = {
    'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
    'PAGE_SIZE': 10,
    'DEFAULT_AUTHENTICATION_CLASSES': (
        'rest_framework_simplejwt.authentication.JWTAuthentication',
    )
}

When I run $ python manage.py runserver I get this error

ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ModuleNotFoundError: No module named 'rest_framework_simplejwt'.

I have tried importing it at the top of settings.py like this

import rest_framework_simplejwt

and have tried adding it to my installed_apps.

Nothing is working. Any help here would be greatly appreciated.

Also, I'm following this guide: https://django-rest-framework-simplejwt.readthedocs.io/en/latest/getting_started.html



Solution 1:[1]

make sure that you are using the right env. may there is a difference between the environment that you run 'pip freeze' and the python environment that Django is using.

Solution 2:[2]

I ran into the same error myself, whenever you run into a problem where you're unable to call a package it's mainly due to the fact that it is not installed, try...

pip3 install djangorestframework-simplejwt

credit: https://www.youtube.com/watch?v=I9st-DgQoWc

Solution 3:[3]

You need to restart your machine and install

  • pip install djangorestframework-jwt
  • pip install djangorestframework-simplejwt please ensure those lib's install or not

Click here!Check this link for the installation as well

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ido Cohen
Solution 2 kidMpukane
Solution 3 shine