简体   繁体   English

Mac上的Pygame-如何安装?

[英]Pygame on Mac - How do I install?

Doing this on a mac. 在Mac上执行此操作。 I've installed the package from the website but when I run a script with import pygame it says it doesn't exist. 我已经从网站上安装了该软件包,但是当我使用import pygame运行脚本时,它说该脚本不存在。 Looked online and it says I need to run the configure.py file but I can't seem to locate that file. 在网上看起来,它说我需要运行configure.py文件,但是我似乎找不到该文件。 Any tips? 有小费吗?

Here is my code so far: 到目前为止,这是我的代码:

import pygame  
screen = pygame.display.set_mode((640, 480)) 
running = 1  
while running:
     event = pygame.event.poll()
     if event.type == pygame.QUIT:
         running = 0
     screen.fill((0, 0, 0))
     pygame.draw.line(screen, (0, 0, 255), (0, 0), (639, 479))
     pygame.draw.aaline(screen, (0, 0, 255), (639, 0), (0, 479))
     pygame.display.flip()

The script is probably using a version of python that you did not install pygame into. 该脚本可能使用的是未安装pygame的python版本。

I believe the pygame binary installer (which is what I assume you meant by "package from the website") installs into system python. 我相信pygame二进制安装程序(这是我假设您所说的“来自网站的软件包”的意思)会安装到系统python中。 Check which version you are using by default. 检查默认情况下使用的版本。 This is what it should look like when you run "which python" from Terminal.app: 这是从Terminal.app运行“哪个python”时的外观:

$ which python
/usr/bin/python

This happens all the time if you use MacPorts, Fink, or a Python.org binary installer to install python. 如果您使用MacPorts,Fink或Python.org二进制安装程序来安装python,则始终会发生这种情况。 If you are using MacPorts or Fink, python may have even been installed without your knowledge as a dependency to something else. 如果您使用的是MacPorts或Fink,甚至可能在您不了解python的情况下安装了python。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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