PyDev on Eclipse,代码分析不起作用,无法检测到一些代码错误

PyDev on Eclipse, code analysis doesn't work, some code errors can not be detected

我正在使用 PyDev 在 Eclipse 中编码 python。

有些代码错误无法检测到,只有尝试运行代码才能知道。 正常吗?有没有一些方法可以在我编码时显示这种错误?提前致谢!

例如,对于下面的代码,只有当我 运行 代码时,我才会得到“NameError: name 'User' is not defined”。

from django.db import models

# Create your models here.

class Board(models.Model):
    name = models.CharField(max_length=30,unique=True)
    description = models.CharField(max_length=100)

class Topic(models.Model):
   subject = models.CharField(max_length=225)
   last_update = models.DateTimeField(auto_now_add=True)
   board = models.ForeignKey(Board,models.DO_NOTHING,related_name='topics')
   starter = models.ForeignKey(User,related_name='topics')

它对我有用,所以,我认为这可能是 PYTHONPATH 配置错误。

特别是,您的源代码必须位于源文件夹下才能进行代码分析(源文件夹是添加到 PYTHONPATH 的文件夹)。

有关如何配置源文件夹的详细信息,请参阅:http://www.pydev.org/manual_101_project_conf2.html

如果您认为这不是问题所在,还请在您的屏幕截图中包含 PyDev 包资源管理器(扩展到相关文件)。