簡體   English   中英

出現錯誤 ModuleNotFoundError:沒有名為“rest_framework_sso”的模塊

[英]Getting error ModuleNotFoundError: No module named 'rest_framework_sso'

我正在關注https://pypi.org/project/djangorestframework-sso/ django中的 sso 身份驗證教程,在第一步中,他們在 INSTALLED_APPSin settings.py 中添加了“rest_framework_sso”而不安裝任何此類庫。 當我嘗試做同樣的事情時,我得到了:

ModuleNotFoundError: No module named 'rest_framework_sso'

然后我嘗試了 pip/pip3 install 'rest_framework_sso' 但我得到了:

ERROR: Could not find a version that satisfies the requirement rest_framework_sso (from versions: none)
ERROR: No matching distribution found for rest_framework_sso

然后我安裝了 django rest 框架,但它仍然無法正常工作。

我想知道為什么它不起作用以及如何解決這個問題,我沒有找到任何可以幫助我解決這個問題的東西。

(對於維基方面,我會寫下一個正確的答案,以防以后有人提出問題)

We have to differentiate between two things here: The name of the package on Pypi, which is what you have to use with pip , and the name of the python module that is provided in that package.

For the django rest framework SSO package, the Pypi package name currently is djangorestframework-sso , so that has to be used with pip

pip install djangorestframework-sso

但是,允許您使用的 python 模塊名為rest_framework_sso ,因此當將其添加到INSTALLED_APPS或在 python 中以任何其他方式使用它時,您需要使用此名稱,如文檔中所示:

from rest_framework_sso.views import obtain_session_token
# go on to use obtain_session_token

如果您想知道,有一個關於為什么會這樣的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM