无法安装Django,我收到JWT错误

2024-05-29 09:45:21 发布

您现在位置:Python中文网/ 问答频道 /正文

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

    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'))
]

这是我的设置。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冻结时,我得到以下列表,我认为所有需要的依赖项都存在于虚拟环境中:

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

Tags: pathdjangofrompyimportrestapiauthentication

热门问题