简体   繁体   中英

Trouble Installing Pygame on Mac OSX

Here is my error message:

Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named pygame
>>> 

So 2.7 can't find pygame. This is on a new installation of python, and I'm able to get to my other modules (pyo,wx,numpy). I have reinstalled pygame and looked among the respective library folders and I can't find the pygame module anywhere. A reinstallation does not fix this. Any Advice?

EDIT: In response to questions as to how I installed pygame, I installed from the .dmg located here http://www.pygame.org/download.shtml 'pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg '

The instructions differ if you have a 32-bit proccessor or a 64-bit one. Users of 32-bit processors should just download and install the binary labeled pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg on the pygame download page . Users of 64-bit processors should follow the instructions below.

  1. There is no 64-bit version of pygame for Mac OS X. The 32-bit version of pygame is only compatible with a 32-bit version of python. However, there is a warning/caution to be aware of: on Snow Leopard the Apple-provided version of Tcl/Tk (a GUI library which powers IDLE) can be out-of-date and cause problems. Snow Leopard users should first download and install an updated version from here , labeled ActiveTcl 8.4.19.5 under Mac OS X (Universal). This should be installed first. Lion users should ignore this step.

  2. Delete, if already installed, the Python 2.7 folder (most likely in /Applications). This is most likely the 64-bit version of Python that should not be used.

  3. Download and install the 32-bit version of Python 2.7.2 provided here under Python 2.7.2 Mac OS X 32-bit i386/PPC Installer. Regardless of what download page says, this version is compatible on Mac OS X Lion. If you have the correct version, the install size (as displayed in Installer) should be around 90 MB.

  4. Download and install the 32-bit version of pygame, located here .

  5. You can test to see if this has worked by opening IDLE, and typing: import pygame

If there is no output, it worked. If instead you get a "no matching architecture in universal wrapper" error, then most likely step 2 was skipped.

Another workaround is to copy the pygame module directly into your project directory.

The path to pygame on my mac after installing the binary is "/Library/Python/2.7/site-packages/pygame".

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