I'm a beginner and so far I have about 3 hours invested installing pygame( ie getting the python interpreter to accept 'from livewires import games, color' to check both 'pygame' and 'livewires' have installed).
However, when I ran my first source code I got this:
Traceback (most recent call last):
File "C:/Python31/Coding/pygame.py", line 4, in <module>
from livewires import games
File "C:\Python31\lib\site-packages\livewires\games.py", line 57, in <module>
import pygame, pygame.image, pygame.mixer, pygame.font, pygame.transform
File "C:/Python31/Coding\pygame.py", line 4, in <module>
from livewires import games
ImportError: cannot import name games
>>>
Why might this be happening? Does anyone have some pointers? I don't have any hours left to figure it out myself, what with a full-time job and life matters.
Thanks,
Dave
Code:
# New graphics window
# Demo's creating a graphics window
from livewires import games
# initialize graphics screen
games.init(screen_width = 640, screen_height = 480, fps = 50)
# start mainloop
games.screen.mainloop()
You naming your code script pygame.py
which rises a conflict with pygame
library. Change the name and try it again.
This happens when you try to import
from livrewires
and in your current working directory there is a script named livrewires.py
. Rename your livewires.py
script to something else.
Try to avoid using modules names as your scripts names
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.