Pygame.init() not working [duplicate]

岁酱吖の 提交于 2019-12-01 14:47:55

You probably had named your file pygame.py
when you type:

import pygame

python won't import pygame module you want, instead it will try import local module pygame - your file. and your file hasn't method init. try change file name from pygame.py to mypygame.py.

I had the same problem, but then I reinstalled everything and realized that I had a different version of pygame than I needed for python

I realized also that I shouldn't use the .zip archive to install. I looked in there and saw that there's an installer for it if you're on any major OS. For example, for Macintosh, there's .dmg files. For Windows, there's .msi, etc.

You probably installed your pygame library in the include/ folder, but somehow didn't have the correct files inside it. This may of happened because of some downloading issues or the website you were downloading from. Hope this helps! You want to type downloading pygame from pygame.org instead of some other places on the web because of possible errors or changes in code.

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