未解决的参考:PyCharm 中的“django"错误 [英] Unresolved reference: 'django' error in PyCharm

查看:29
本文介绍了未解决的参考:PyCharm 中的“django"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试导入:

from django.db import models

PyCharm 下划线 django.db 并抱怨:Unresolved reference 'django'.

PyCharm underlines django.db and complains: Unresolved reference 'django'.

如何让 PyC​​harm 识别 Django?

How do I get PyCharm to recognize Django?

推荐答案

我假设您使用的 virtualenv 与其他项目文件位于同一目录中.Python 应该确切地知道那条路径.所以,很可能是 Pycharm 使用了错误的解释器.

I assume you're using a virtualenv which is located in the same directory as other project files. Python should know exactly that path. So, it's possibly that Pycharm is using the wrong Interpreter.

进入设置->项目:->项目解释器->切换到正确的路径

Go to Settings -> Project: -> Project Interpreter -> switch to the right path

在解释器包中,应该安装 Django 包.如果没有,请在此处/在终端中执行.

In the interpreter packages, there should be Django package installed. If not, do it here/in terminal.

这篇关于未解决的参考:PyCharm 中的“django"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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