我正在一个opencv项目上运行pylint,并且在VS代码中我得到了许多关于成员不在场的pylint错误。
示例代码:
import cv2
cv2.imshow(....)
获得的错误:
但是,代码运行正常,没有任何错误。
版本: pylint 1.8.1,星体1.6.0
发布于 2018-08-19 08:56:30
这是皮林特寄来的。您可以使用以下命令在项目的根目录中生成一个pylint配置文件:(我发现如果您在一个团队中工作,或者在来自同一回购的不同计算机上工作,这是很有帮助的)。
pylint --generate-rcfile > ~/.pylintrc
在生成的.pylintrc文件的开头,您将看到
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=
添加cv2,这样您就可以以
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code.
extension-pkg-whitelist=cv2
保存文件。皮棉的错误应该消失。
发布于 2020-01-10 04:59:46
做好了,对我有用
注意:请确保选择"Preferences: Open (JSON)",而不是"Preferences:(JSON)“
将文件设置为
{
"workbench.iconTheme": "vscode-icons",
"python.dataScience.sendSelectionToInteractiveWindow": true,
"kite.showWelcomeNotificationOnStartup": false,
"python.dataScience.askForKernelRestart": false,
"python.dataScience.jupyterServerURI": "local",
"python.pythonPath": "/usr/bin/python3",
"workbench.colorTheme": "Monokai",
"vsicons.dontShowNewVersionMessage": true,
"python.linting.pylintArgs": ["--generate-members"] }
发布于 2020-04-07 10:31:07
尝试像这样导入cv2:
from cv2 import cv2
https://stackoverflow.com/questions/50612169
复制相似问题