python - 无法导入 : 'unable to import rest_framework' when importing serializer?(Windows)

标签 python django django-rest-framework

我的 settings.py 的 INSTALLED_APPS 中有“rest_framework”,我可以在 cmd 中毫无问题地导入它

enter image description here

但我收到“无法导入 'rest_framework'”消息

enter image description here

我可以在我的cmd提示符下导入rest_framework没问题,所以我真的不知道问题是什么?

最佳答案

vs code_taskbar 我看到你正在使用 VS Code。快速解决方法是转到 VS Code 左下角 [任务栏] 的 Python 环境设置-> 点击 [Python 2/3...],它会提示您从默认 Python 中选择环境安装目录到您的项目虚拟环境(venv)目录,这应该可以解决所有导入问题。

关于python - 无法导入 : 'unable to import rest_framework' when importing serializer?(Windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54507725/

相关文章:

python - DRF(django-rest-framework) Action 装饰器不工作

python - 是否可以将 Flask 中的 "app factory"模式用于 Click CLI 应用程序?

python - pyPDF2 中的 extractText() 函数抛出错误

python - 多线程与多处理 : Which one to select?

python - Django - 在离开站点之前更新数据库行的链接

python - 有人可以建议如何实现自定义 Django PasswordResetView 吗?

python - 如何提供 API 来获取 django-rest 中任何模型的更改历史记录?

python - 如何从完全不同的 ADB 工作区访问一个 ADB 工作区的 dbfs 存储中的文件/表

python - Django / python : screen sharing api

django - 如何防止Django将管理URI覆盖到/admin而不是/api/admin/