vscode中PyLint报错Unable to import解决方案
生活随笔
收集整理的這篇文章主要介紹了
vscode中PyLint报错Unable to import解决方案
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
在導入其它文件夾中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
總結
以上是生活随笔為你收集整理的vscode中PyLint报错Unable to import解决方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Solidworks公司电脑图纸被加密之
- 下一篇: Heap(堆结构/优先队列)-Swift