I have installed pygames on my mac, using the installer in the following package found on the pygame.org site: pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg.
I have installed python with the Python 2.7.2 Mac OS X 64-bit/32-bit x86-64/i386 Installer found on python.org, and ran easy_install pyobjc
so that I now have pyobjc 2.2 installed.
But when I try the to import pygame in the repl, I get this:
>>> import pygame
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
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
The Python "ModuleNotFoundError: No module named 'pygame'" occurs when we forget to install the pygame module before importing it or install it in an incorrect environment. To solve the error, install the module by running the pip install pygame command.
Open a terminal, and type 'sudo apt-get install idle pygame', enter your password and type 'y' at the prompts, if necessary. 2. After the installation completes, enter 'python' in the terminal to launch Python. Verify that it's using version 2.7 or newer, then at the Python prompt enter 'import pygame'.
Pygame on Python 3.8 You should use the same command you use to run a Python terminal session on your system, which might be python , python3 , py , python3. 8 , or something else. If you've had any issues running Pygame on macOS, this version of Pygame should address those issues as well.
I admit this is a guess, but could this be a 32 vs. 64 bit issue?
If I do:
file /usr/bin/python
I get:
python: Mach-O universal binary with 2 architectures
python (for architecture x86_64): Mach-O 64-bit executable x86_64
python (for architecture i386): Mach-O executable i386
Wondering what you see on your add-in file?
For example, if it's 32 bit, then run Python that mode:
arch -i386 /usr/bin/python
If that's not exactly it, at least this will hopefully get you in the right direction.
This was a 32 bit vs 64 bit issue for me. I followed the directions listed here: http://web.mit.edu/6.090/www/pygame.html and the issue was resolved.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With