Importerror: Could Not Import 'rest_framework_simplejwt.authentication.jwtauthentication'
Solution 1:
It seems you are confusing two packages. djangorestframework-jwt
which you have in your requirements.txt is no longer maintained. It provides the rest_framework_jwt.authentication.JSONWebTokenAuthentication
authentication class.
However, the one you are actually using, rest_framework_simplejwt.authentication.JWTAuthentication
, comes from the pip package djangorestframework_simplejwt
So you need to update your requirements.txt. Remove djangorestframework-jwt
and add djangorestframework_simplejwt
Solution 2:
If anyone still encountering this error, this is the requirements for djangorestframework-simplejwt:
Python (3.6, 3.7, 3.8)
Django (2.0, 2.1, 2.2, 3.0)
Django REST Framework (3.8, 3.9, 3.10)
I downgraded Django & DRF and the problem is solved for me.
pip uninstall django
pip uninstall djangorestframework
pip install --upgrade django==3.0
pip install --upgrade djangorestframework==3.10
pip install djangorestframework-simplejwt
Solution 3:
for me the djangorestframework-simplejwt
upgrade from 4.4.0
to current latest version 4.6.0
fixed the problem.
pip3 install --upgrade djangorestframework-simplejwt
Solution 4:
I encountered same error when attempting to deploy on Heroku
Upon investigating I found 2 issues in my case:
1] requirements.txt --> This file was not updated and therefore 'git add' and 'git commit' did not pickup the new requirement for djangorestframework-simplejwt
So the solution here was to do a fresh pip freeze > requirements.txt, git add/commit and confirm that on Heroku
2] Secondly I found that Heroku was not finding the v4.6.0 which my python3.8 had installed locally. Instead, I had to edit the requirements.txt to v4.4.0 (current on the pypi.org), redo the git add/commit before this problem was resolved
Solution 5:
For me issue solverd by restarting virtual environment
Post a Comment for "Importerror: Could Not Import 'rest_framework_simplejwt.authentication.jwtauthentication'"