While writing some Python code in Visual Studio Code that calls some Numpy classes, Pylint error messages appear complaining about non-existing Numpy members, e.g. the log2 method, and red wavy lines underline the offending code, as shown in the screenshot below. 报错内容。
One way to clear this up is to get Pylint to white-list Numpy using Visual Studio Code's Settings.
- In Visual Studio Code, select File | Preferences | Settings.
The settings.json file is displayed in the editor. 在Settings中搜索找到“settings.json”。 
- Click the Workspace Settings tab.
The settings appear in the editor.
- In the editor, type in the following and save the file.
在json文件中写入{ "python.linting.pylintArgs" : [ "--extension-pkg-whitelist=numpy" ] }
- Close and reopen the folder in Visual Studio Code.
The missing member messages and the red wavy underlines no longer appear. 报错消失。
本文介绍如何通过配置Visual Studio Code的Pylint插件,来避免在使用Python和Numpy进行编程时出现的错误提示。通过在settings.json文件中添加特定设置,可以有效地消除Pylint对于Numpy成员不存在的误报。
631

被折叠的 条评论
为什么被折叠?



