简体   繁体   中英

How do I import pygame on 3.7.1?

I'm running python 3.7.1 on my MacBook and it has been running perfectly until I tried importing pygame. I'm taking an intro to python class and we always just do from module import * . When I tried to do that same format with pygame I just got an error ModuleNotFoundError: No module named 'pygame'

What should I do about using pygame or should I just forget using pygame altogether

I'm new to python and the reason I'm trying to use pygame is that I'm making a game where the user controls a .gif or a spaceship and tries to avoid asteroids. All of my code is solid accept for the collision detection. Everyone seems to point me towards using pygame but i can't get that to work. Should I continue to use pygame and if so, how do i fix my problem? Should I drop pygame altogether and just try collision detection a different way; (if so, what other way?)

pygame is not bundled in standard python.

to install pygame in Mac, see Mac installation from pygame.org

Also, from module import * is not a good practice if you're using more modules,

which will causes class name conflicts.

最简单的方法-忘记3.7.1进入Python网站(链接)并下载3.6.7,然后在设置时单击“添加到PATH”,然后需要安装pygame(将其保存在保存python的位置附近)通过转到finder并单击应用程序,然后在终端上搜索终端,然后键入pip install pygame如果您有任何pip install pygame ,只需问(:: Path button

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM