如何让PyLint识别numpy成员? [英] How do I get PyLint to recognize numpy members?

查看:165
本文介绍了如何让PyLint识别numpy成员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Python项目上运行PyLint. PyLint抱怨无法找到numpy成员.在避免跳过成员资格检查的同时如何避免这种情况.

I am running PyLint on a Python project. PyLint makes many complaints about being unable to find numpy members. How can I avoid this while avoiding skipping membership checks.

从代码中:

import numpy as np

print np.zeros([1, 4])

哪个,当我运行时,我得到了预期的结果:

Which, when ran, I get the expected:

[[0. 0. 0. 0.]]

[[ 0. 0. 0. 0.]]

但是,pylint给了我这个错误:

However, pylint gives me this error:

E:3、6:模块"numpy"没有零"成员(无成员)

E: 3, 6: Module 'numpy' has no 'zeros' member (no-member)

对于版本,我使用的是pylint 1.0.0(星号1.0.1,常见的0.60.0),并尝试使用numpy 1.8.0.

For versions, I am using pylint 1.0.0 (astroid 1.0.1, common 0.60.0) and trying to work with numpy 1.8.0 .

推荐答案

如果将 Visual Studio代码与Don Jayamanne出色的 Python扩展,将用户设置添加到numpy白名单:

If using Visual Studio Code with Don Jayamanne's excellent Python extension, add a user setting to whitelist numpy:

{
    // whitelist numpy to remove lint errors
    "python.linting.pylintArgs": [
        "--extension-pkg-whitelist=numpy"
    ]
}

这篇关于如何让PyLint识别numpy成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆