Resolving Python Module 'numpy' has no 'xxxx' member error message in Visual Studio Code

本文介绍如何通过配置Visual Studio Code的Pylint插件,来避免在使用Python和Numpy进行编程时出现的错误提示。通过在settings.json文件中添加特定设置,可以有效地消除Pylint对于Numpy成员不存在的误报。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

  1. In Visual Studio Code, select File | Preferences | Settings.

    The settings.json file is displayed in the editor在Settings中搜索找到“settings.json”。
  2. Click the Workspace Settings tab.

    The settings appear in the editor.
  3. In the editor, type in the following and save the file.

    在json文件中写入{ "python.linting.pylintArgs" : [ "--extension-pkg-whitelist=numpy" ] }

  4. Close and reopen the folder in Visual Studio Code.

    The missing member messages and the red wavy underlines no longer appear. 报错消失。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值