Error importing the installed pygame module

吃可爱长大的小学妹 提交于 2019-12-11 17:19:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!