Reputation: 11
I'm trying to install pygame
on my mac, when I import pygame
, below error returned
Traceback (most recent call last): File "<pyshell#0>", line 1,
in <module> import pygame File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/__init__.py", line 95,
in <module> from pygame.base import * ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so, 2): no suitable image found.
Did find: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame/base.so: no matching architecture in universal wrapper.
I have seen it is a architecture problem, however I'm not aware of how to install 32bit python.
Thanks in advance
Upvotes: 1
Views: 23431
Reputation: 292
I had to use these instructions in order for it to work on MAC OS 10.14.4 with Python 3.8 on date 6/2/20, assuming you already have Python installed.
brew install mercurial
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
brew install smpeg
pip install https://github.com/pygame/pygame/archive/1.9.4.zip
Upvotes: 2
Reputation: 369
For me actually, in 03/2020 with the latest OS / Python etc. I used all commands except for the last one which did not work. I simply run this and SUCCESS(!):
pip3 install pygame
Upvotes: 5
Reputation: 1743
EDIT: I realized that these steps were originally intended for python3. It should still work for python2, but I can't confirm, it's just the best answer I have.
Assuming you are using the newest macOS, here are the steps I used to install pygame. Try and uninstall what you installed for pygame previously, I'm not sure how this could affect it. This will also install the IDLE program, a python IDE developed by python, if you don't already have it.
If you have an older mac, click the source link at the bottom, which we provide instructions for older macs, which would involve downloading programs like xcode.
Install homebrew. Go into terminal and paste
ruby -e "$(curl -fsSL https<nolink>://raw.githubusercontent.com/Homebrew/install/master/install)"
then hit enter.
Paste the following into terminal, hitting enter after each line:
brew install python
(brew install python3
for python3 users)
brew install mercurial
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
brew tap homebrew/headonly
(if you have any trouble here, try brew install --HEAD smpeg
instead)
brew install smpeg
sudo -H pip install hg+http<nolink>://bitbucket.org/pygame/pygame
(You will have to enter your password, and you must be an admin. Python3 users should use sudo -H pip3 install hg+http<nolink>://bitbucket.org/pygame/pygame
)
Source (although some info was updated)
Upvotes: 4