I've installed pygame with Anaconda using the following command:conda install --channel https://conda.anaconda.org/kne pygame
Then I tried to import pygame and I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ejalaa/anaconda/lib/python2.7/site-packages/pygame/__init__.py", line 133, in <module>
from pygame.base import *
ImportError: dlopen(/Users/ejalaa/anaconda/lib/python2.7/site-packages/pygame/base.so, 2): Library not loaded: /usr/local/opt/sdl/lib/libSDL-1.2.0.dylib
Referenced from: /Users/ejalaa/anaconda/lib/python2.7/site-packages/pygame/base.so
Reason: image not found
What does that mean ? Any idea how I can solve it?
Thank you.
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'.
Because the PyGame is only supported python 3.7. 7 or higher version so make sure you are using the latest version of python.
A. Check if you have a 64 or 32 bit version pygame and make sure your version of python is the same.
B. Use something like pip install or any other type of method to install pygame.
C. Install a previous version of pygame and python, you might have some more luck with that.
The error is basically saying that a class in pygame called image could not be found. Obviously pygame has not been installed properly so I would suggest using the above methods to install it again.
I hope this helps!
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