0

I just recently began learning pygame, but whenever I try to run anything, it always throws up an error. On windows btw

To start I have:

import pygame
pygame.init()

win = pygame.display.set_mode((500,500))
pygame.display.set_caption("First Game")

After this, I have my general program. Whenever I use "pygame."... it throws up an error code in VS code and when I attempt to run the program it says, File "c:/Users/liame/Python Projects/pygame.py", line 1, in import pygame File "c:\Users\liame\Python Projects\pygame.py", line 2, in pygame.init() AttributeError: partially initialized module 'pygame' has no attribute 'init' (most likely due to a circular import)

The directory is: "pythonprojects -> pygame.py" and that's it.

To import it, I've tried, "pip install pygame," and, "py -m pip intall -U pygame --user"

I really need help with this because I can't get anywhere in the meantime

Liam Brem
  • 11
  • 2
  • 3
    You've named *your own script* `pygame.py`, so that's what `import pygame` is loading. Rename it to something that doesn't conflict with module names you're trying to use. – jasonharper Mar 07 '20 at 03:10
  • @jasonharper - I renamed the file to something different, but it still throws up an error for pygame.init() whenever I run it. – Liam Brem Mar 07 '20 at 17:06
  • Make sure there's no `pygame.pyc` or `pygame.pyo` file left around in the folder with your script. – jasonharper Mar 07 '20 at 19:02

0 Answers0