Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pygame installation issue in mac os

Tags:

python

pygame

I have following issue of installing pygame package.

In file included from src/_numericsurfarray.c:23: src/pygame.h:106:10: fatal error: 'SDL.h' file not found #include <SDL.h>          ^ 1 error generated. error: Setup script exited with error: command 'gcc' failed with exit status 1 

System information

  • Mac OS-10.9.2
  • python version- Python 2.7.5 :: Anaconda 1.6.1 (x86_64)

Any suggestion will be greatly appreciate ? Thanks.

like image 752
J4cK Avatar asked Apr 09 '14 21:04

J4cK


People also ask

Can you install pygame on Mac?

Installing PyGameIf you don't see any errors, it means that PyGame has been successfully installed on your Mac.

Why is my pygame not working?

The Python error "ModuleNotFoundError: No module named 'pygame'" occurs for multiple reasons: Not having the pygame package installed by running pip install pygame . Installing the package in a different Python version than the one you're using. Installing the package globally and not in your virtual environment.

Does Python 3.10 support pygame?

Python doesn't support Pygame.


2 Answers

Here (OSX Mavericks) I got able to install this way:

brew install sdl sdl_image sdl_mixer sdl_ttf portmidi pip install https://bitbucket.org/pygame/pygame/get/default.tar.gz 

("default" branch is on commit e3ae850 right now)

Source: https://bitbucket.org/pygame/pygame/issue/139/sdlh-not-found-even-thought-it-exists#comment-3822470

See this other StackOverflow question too: PyGame in a virtualenv on OS X with brew?

like image 116
alanjds Avatar answered Sep 28 '22 00:09

alanjds


I had the same issue. I tried all versions of the answers to this question including variations of pip and pip3. Finally, the one that worked for me was:

sudo easy_install pygame

Note, however, that: (1) https://setuptools.readthedocs.io/en/latest/easy_install.html says that easy_install is deprecated and recommends using pip. (2) pygame is installed in the old standard python 2.7 folder rather than in the python 3.8.3 that I just installed -- though I was able to use it successfully in VSCode.

like image 20
Para Parasolian Avatar answered Sep 28 '22 02:09

Para Parasolian