I'm trying to install pygame.
My envrionment is
macOS 10.14.6 Mohave
Python 3.7.4 (downloaded from python.org)
I'm following the instructions on the Pygame site, namely using
pip install pygame
However this is failing with a fatal error, which can be summarised as fatal error:SDL.h filenot found The full install output is shown below.
Running setup.py install for pygame ... error
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-mtm_fm2t/pygame/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-mtm_fm2t/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-vrvsxslr/install-record.txt --single-version-externally-managed --compile
cwd: /private/tmp/pip-install-mtm_fm2t/pygame/
Complete output (219 lines):
running install
running build
running build_py
creating build
creating build/lib.macosx-10.9-x86_64-3.8
creating build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/surfarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/sysfont.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
copying src_py/_camera_vidcapture.py -> build/lib.macosx-10.9-x86_64-3.8/pygame
...whole bunch of copying removed for brevity...
copying examples/pixelarray.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
copying examples/dropevent.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
running build_ext
building 'pygame.gfxdraw' extension
creating build/temp.macosx-10.9-x86_64-3.8
creating build/temp.macosx-10.9-x86_64-3.8/src_c
creating build/temp.macosx-10.9-x86_64-3.8/src_c/SDL_gfx
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -DENABLE_NEWBUF=1 -I/NEED_INC_PATH_FIX -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src_c/gfxdraw.c -o build/temp.macosx-10.9-x86_64-3.8/src_c/gfxdraw.o
In file included from src_c/gfxdraw.c:33:
In file included from src_c/pygame.h:32:
src_c/_pygame.h:216:10: fatal error: 'SDL.h' file not found
#include <SDL.h>
^~~~~~~
1 error generated.
---
For help with compilation see:
https://www.pygame.org/wiki/MacCompile
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
error: command 'gcc' failed with exit status 1
ERROR: Command errored out with exit status 1:
/Library/Frameworks/Python.framework/Versions/3.8/bin/python3 -u -c 'import sys,
setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-
mtm_fm2t/pygame/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-
mtm_fm2t/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /private/tmp/pip-record-vrvsxslr/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.
The file SDL.h does exist when I search in finder, so i don't know why this install is failing.
I've tried the following to solve this but with no success.
- installing with pip3 install pygame
- installing with pip3 install pygame--2.0.0_dev4 option
- And i've even tried downloading the SDL2 source and compiling.
They all fail (the SDL make fails chronically with errors around lzma.h
Has anyone got pygame running on macOS and Python 3.7.4 and can provide a list of detailed instructions and pre-requisites.