vscodeでのPyLintエラーUnable to importソリューション

1634 ワード

他のフォルダにpyファイルをインポートする場合、コードに指定したパスが追加されても、Pylintでファイルが検出されないため、Unable to import'xxx'のエラーメッセージが表示されます.
プロジェクトディレクトリに追加する必要があります.pylintrcファイルリファレンスファイルが存在するディレクトリを指定
# .pylintrc      pllint       

[MASTER]
# XXX              (./custom_lib)
init-hook='base_dir="XXX"; import sys,os,re; _re=re.search(r".+\/" + base_dir, os.getcwd()); project_dir = _re.group() if _re else os.path.join(os.getcwd(), base_dir); sys.path.append(project_dir)'

[MESSAGES CONTROL]
# Find available symbolic names in:
# https://docs.pylint.org/features.html
disable=locally-disabled,trailing-whitespace,fixme,missing-docstring,protected-access,invalid-name,super-init-not-called,star-args,no-self-argument,inherit-non-class,no-method-argument,no-self-use,unused-argument,too-many-return-statements,too-many-branches,too-many-function-args,too-many-instance-attributes,too-many-locals,bad-continuation,unnecessary-lambda,redefined-variable-type,global-statement,line-too-long,mixed-indentation,bad-whitespace,missing-final-newline

 
転載先:https://www.cnblogs.com/wangyunjie/p/8855943.html