pylint_django抛出异常

时间:2017-12-17 22:06:45

标签: python django pylint

我正在使用Python v3.6,Django v2.0并且遇到了pylint_django的问题。

首先,如果我运行" pylint民意调查/"在一个运行良好的文件夹上运行它,并显示该文件夹中所有文件的所有代码问题。由于django框架,有一堆错误显示错误显示,我被告知使用pylint_django插件将摆脱这些错误。

我已经使用" pip install pylint_django"安装了该插件,但是当我尝试使用此插件运行pylint时,它出错了:

C:\Users\Michael\Dev\DjangoProject>pylint --load-plugins pylint_django polls/
Traceback (most recent call last):
  File "c:\users\michael\appdata\local\programs\python\python36-32\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\michael\appdata\local\programs\python\python36-32\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Michael\Envs\Django\Scripts\pylint.exe\__main__.py", line 9, in <module>
  File "c:\users\michael\envs\django\lib\site-packages\pylint\__init__.py", line 16, in run_pylint
    Run(sys.argv[1:])
  File "c:\users\michael\envs\django\lib\site-packages\pylint\lint.py", line 1268, in __init__
    linter.load_plugin_modules(self._plugins)
  File "c:\users\michael\envs\django\lib\site-packages\pylint\lint.py", line 495, in load_plugin_modules
    module.register(self)
  File "c:\users\michael\envs\django\lib\site-packages\pylint_django\plugin.py", line 22, in register
    start = name_checker.config.const_rgx.pattern[:-2]
AttributeError: 'NoneType' object has no attribute 'pattern'

任何人都知道我可能做错了什么?

由于

1 个答案:

答案 0 :(得分:4)

似乎pylint>=1.8不喜欢pylint_django==0.7.2,尝试使用pip install 'pylint>=1.7,<1.8'降级它。