首页 > 解决方案 > 无法安装 django,我收到 JWT 错误

问题描述

当我尝试安装 django(在 Google 云上)时,我收到以下消息:

    File "/root/lplatform/back/lplatform_api/urls.py", line 3, in <module>
    from rest_framework_simplejwt.views import TokenObtainPairView, TokenRefreshView, TokenVerifyView
ModuleNotFoundError: No module named 'rest_framework_simplejwt'

这是我的 url.py 文件:

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('lplatform_api.urls'))
]

这是我的setting.py:

REST_FRAMEWORK = {
    "DEFAULT_PERMISSION_CLASSES": (
        "rest_framework.permissions.IsAuthenticated",
    ),
    "DEFAULT_AUTHENTICATION_CLASSES": (
        "rest_framework_simplejwt.authentication.JWTAuthentication",
        'rest_framework.authentication.BasicAuthentication'
,        'rest_framework.authentication.SessionAuthentication',
    ),
}

当我执行 pip freeze 时,我得到下面的列表,我认为所有需要的依赖项都存在于虚拟环境中:

asn1crypto==0.24.0
cryptography==2.1.4
Django==1.11.29
djangorestframework==3.9.4
djangorestframework-jwt==1.11.0
djangorestframework-simplejwt==4.1.4
enum34==1.1.6
idna==2.6
ipaddress==1.0.17
keyring==10.6.0
keyrings.alt==3.0
pycrypto==2.6.1
pygobject==3.26.1
PyJWT==1.7.1
pytz==2019.3
pyxdg==0.25
SecretStorage==2.3.1
six==1.11.0

标签: pythondjangorest

解决方案


推荐阅读