LoginSignup
10
7

More than 5 years have passed since last update.

VSCode上で、Python3.7の時、pylintで1行目に出たエラーと解決法

Last updated at Posted at 2018-07-06

VSCode上で、Python3.7の時、pylintで1行目に出たエラー

Python3.7にして、VSCodeで、コード書いていたら、
なにも間違ったこと書いていないのに、1行目にエラーが!
絶対間違ったこと書いてないのに、、、
だって

import sys
import os

しか書いてないし。

出てきたエラー

[pylint] F0002:<class 'RuntimeError'>: generator raised StopIteration (1,1)

え?Iteratorなんて回してないし。。。

調査

とりあえず、VSCodeの設定が悪いのかどうかを切り離したかったので、
コンソール開いて、pylintしてみた。

Traceback (most recent call last):
  File "/Users/takashi/Dev/env/lib/python3.7/site-packages/astroid/decorators.py", line 89, in wrapped
    res = next(generator)
StopIteration

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/takashi/Dev/env/lib/python3.7/site-packages/astroid/decorators.py", line 104, in wrapped
    raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

~ 省略 ~

お?こっちでも失敗。
問題は、python3.7のastroid/decorators.pyで発生してるっぽい。

解決法

コンソールからのpylintのエラー解消

調べてみたら、これが。
おぉまさしくこれっぽいということで、書いてある通り、
pip install pylint astroid --pre -U
したら、コンソールからのpylintではエラーが解消された。

VSCode上でのpylintのエラー解消

ただしまだ、VSCode上では、同じエラーが出ていた。
そこでよくよく考えたら、
virtualenv使ってenv環境でやってるのに、VSCodeでのPythonの設定ってそのままでいいのか?
と思い確認。
"python.linting.pylintPath"という項目の設定を、
"pylint"から"env/bin/pylint"に変更してみたら、
エラーが解消された。

10
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
7