Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does it say that module pygame has no init member?

This is the code I have:

import pygame pygame.init() 

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' has no 'init' member

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.

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.

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.

like image 862
Ludde Avatar asked May 28 '18 15:05

Ludde


People also ask

What is pygame init () in python?

From www.pygame.org. pygame. init() initialize all imported pygame modules. No exceptions will be raised if a module fails, but the total number if successful and failed inits will be returned as a tuple.

Why we use pygame init ()?

init() initialize all imported pygame modules is a convenient way to get everything started. The init() functions for individual modules will raise exceptions when they fail.

How do I import and use pygame?

Open a terminal, and type 'sudo apt-get install idle pygame', enter your password and type 'y' at the prompts, if necessary. 2. After the installation completes, enter 'python' in the terminal to launch Python. Verify that it's using version 2.7 or newer, then at the Python prompt enter 'import pygame'.


1 Answers

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" ] 

I no longer see the pyinit error.

like image 167
Parkofadown Avatar answered Sep 22 '22 00:09

Parkofadown