为什么说 pygame 模块没有 init 成员? [英] Why does it say that module pygame has no init member?

查看:111
本文介绍了为什么说 pygame 模块没有 init 成员?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

import pygame
pygame.init()

我很困惑,因为如果我尝试运行该文件,那么似乎没有问题,但是 pylint 说如下:

I'm very confused because if I try to run the file, then there seems to be no issue, but pylint says the following:

E1101:Module 'pygame' 没有 'init' 成员

E1101:Module 'pygame' has no 'init' member

我已经彻底搜索了这个错误"的解决方案.在我发现的每个相关案例中,解决方案是确保我没有创建另一个名为pygame"的文件或文件夹,因为在这种情况下,我只会导入我自己的文件或文件夹.

I have searched thoroughly for a solution to this "error". In every relevant case I found, the solution was to make sure that I have not made another file or folder with the name "pygame", because in that case, I would just be importing my own file or folder.

但是,我没有创建名称甚至接近pygame"的文件夹或文件,所以我不知道问题是什么.

However, I have not made a folder or file with a name even close to "pygame", so I don't know what the problem is.

如前所述,我似乎可以毫无问题地运行该文件,并且在我的学习过程中出现这样的错误使我感到困惑.

As said earlier, it seems like I'm able to run the file without any issues and having errors like this confuses me in my learning process.

我在 Visual Studio Code 中编写代码,我使用的是 python 3.6,我使用的是 pygame 1.9.3 并更新了我的 pylint.任何帮助将不胜感激.

I write code in Visual Studio Code, I'm using python 3.6, I'm using pygame 1.9.3 and have updated my pylint. Any help would be appreciated.

推荐答案

如果你有 VS 代码,进入你的 .vscode 文件夹 > settings.json 或搜索 python.linting.mypyArgs 在用户设置选项卡下粘贴在花括号之间

If you have VS code, go in your .vscode folder > settings.json or search for python.linting.mypyArgs Under user settings tab paste inbetween curly braces

"python.linting.pylintArgs": [
    "--extension-pkg-whitelist=lxml"  // The extension is "lxml" not "1xml"
]

我不再看到 pyinit 错误.

I no longer see the pyinit error.

这篇关于为什么说 pygame 模块没有 init 成员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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