2

I am trying to import and use pygame:

import pygame

pygame.init()

I use Visual Studio Code and I get the issue saying "Module 'pygame' has no 'init' member".

I have already tried to edit the settings with multiple versions of this:

"python.linting.pylintArgs": [
"----extension-pkg-whitelist=1xml"
]

But it does not work for me. Is there any other way to fix this?

Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
  • 2
    You have most likely named your script (or some other script) `pygame.py`, so that it's being imported instead of the actual `pygame` module. If this is the case, doing `import pygame; print(pygame.__file__)` will show the location of the offending file. – jasonharper May 17 '19 at 18:52
  • Thanks, I hadn't considered that before. But I just checked and it imports the correct pygame. No other script named that. – Berry Bloom May 17 '19 at 21:39
  • What does `dir(pygame)` show? If it doesn't show an `init` attribute then it doesn't exist on the module you're importing named `pygame` (you can look at `pygame.__file__` to see exactly which file Python is importing for that name). – Brett Cannon May 24 '19 at 22:49

0 Answers0