繁体   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