问题
I'm currently doing a project on my school pc and I want to use pygame
, since I have experience with pygame
. I have downloaded pygame
using this line in the command prompt python -m pip install -U pygame --user
when I try this line python3 -m pygame.examples.aliens
that is used to see if pygame
is downloaded right, it works fine.
But, when I import it in the project I get this error message
File "C:/Users/user/Documents/Programming/test.py", line 10, in import pygame
ModuleNotFoundError: No module named 'pygame'
extra info: I use Spyder It is a Windows pc
Thanks in advance :)
回答1:
If you have used pygame before this, then have a look if you have any files named pygame.py
as I had the same problem as you and my problem was naming a file the same as a core module so check that.
I have done the commands that you put and on the python3 -m pygame.examples.aliens
. I got a ModuleNotFoundError: No module named 'pygame'
.
When I changed the second command to python
instead of python3
it worked after I installed pygame like this pip install pygame
to uninstall pygame from how you did it when you install pygame change it to uninstall then try this version.
来源:https://stackoverflow.com/questions/55078224/error-importing-the-installed-pygame-module