這個(gè)錯(cuò)誤是由于pylint為了安全起見(jiàn)懂拾,忽略第三方庫(kù)引起的岖赋,解決方法就是將torch這個(gè)庫(kù)加入到白名單中瓮孙,不要對(duì)其進(jìn)行檢查
1.打開(kāi)vscode的個(gè)人設(shè)置
- On Windows/Linux - File > Preferences > Settings
- On macOS - Code > Preferences > Settings
- 點(diǎn)擊右上角的Open Settings(JSON)
2.在設(shè)置中添加以下代碼
// whitelist torch to remove lint errors
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=torch",
"--ignored-modules=torch",
"--ignored-classes=torch",
]
PS:
- 將代碼中的torch改成別的庫(kù),比如numpy脸甘,也是適用的
- 別的人只需要添加第一個(gè)就行了,而我需要三個(gè)都加上去才有用= = 不知道什么問(wèn)題