【问题标题】:Strange Pylint Error on Python 3.7 import commandPython 3.7 导入命令出现奇怪的 Pylint 错误
【发布时间】:2018-12-15 04:54:22
【问题描述】:

一直在尝试在 Visual Studio 代码 1.25 中将 Pylint 1.9.2 与 Python 3.7 和 Flask 1.0.2 一起使用,

我在代码第一行的 Pylint 上不断收到以下错误。

F0002:: 生成器引发 StopIteration

{
"resource": "/d:/social network/models.py",
"owner": "python",
"code": "F0002",
"severity": 8,
"message": "F0002:<class 'RuntimeError'>: generator raised StopIteration",
"source": "pylint",
"startLineNumber": 1,
"startColumn": 1,
"endLineNumber": 1,
"endColumn": 1
}

我完全不知道这个错误的原因是什么。

  1. 无论我的代码内容如何都会出现(我尝试了“import datetime”和 from peewee import *,两者都有相同的错误)

  2. 只出现在整个项目的一个文件中。其他文件有模块导入,但没有看到这个错误。

如果您知道导致此错误的原因,请提供帮助!

谢谢!

【问题讨论】:

    标签: python python-3.x exception visual-studio-code pylint


    【解决方案1】:

    PyLint 1.9.2 不支持 Python 3.7。 Python 3.7 支持可从他们的预览版中获得,您可以使用

    pip install pylint astroid --pre -U
    

    【讨论】:

    • 谢谢!已回滚到 Python 3.6.5 以等待其他模块赶上。在 python 3.7 上也遇到 peewee 的意外错误。
    【解决方案2】:

    使用pip install pylint astroid --pre -U会报错,使用

    pip install pylint --pre -U
    

    相反。这对我来说运行良好,这也将 astroid 更新到最新的预发行版。

    【讨论】:

      【解决方案3】:

      pylint 和 astroid 2.X 现在支持 Python 3.7,您可以使用 pip 获取它们。目前 pylint 为 2.1.1,而 astroid 为 2.0.4。

      【讨论】:

        猜你喜欢
        • 2023-01-30
        • 2021-02-22
        • 2021-07-21
        • 1970-01-01
        • 2011-03-26
        • 1970-01-01
        • 2015-12-24
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多