导入序列化程序时无法导入:“无法导入rest_framework"?(视窗) [英] Can't import: 'unable to import rest_framework' when importing serializer? (windows)

查看:102
本文介绍了导入序列化程序时无法导入:“无法导入rest_framework"?(视窗)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have 'rest_framework' in my INSTALLED_APPS of settings.py and I can import it with no problem in cmd

但是我收到无法导入'rest_framework'"消息

But I receive an "Unable to import 'rest_framework'" message

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

I can import rest_framework no problem in my cmd prompt, so I really have no idea what the issue is?

推荐答案

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

vs code_taskbar I see you're using VS Code. A quick fix is to go to the Python environment settings at the bottom-left corner[Taskbar] of the VS Code-> tap on [Python 2/3...] and it will prompt you to choose the environment from the default Python installation directory to your Project Virtual Environment(venv) directory and that should fix all the import issues.

这篇关于导入序列化程序时无法导入:“无法导入rest_framework"?(视窗)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆