はじめに
$ sudo pip3 install pygame
pipコマンドでpygameをインストールしようとすると、下記のエラーが出た。
「error: command ‘clang’ failed with exit status 1 」
困ったので、対象方法を記す。
環境:mac
エラー詳細
・・・(中略)・・・ building 'pygame.gfxdraw' extension creating build/temp.macosx-10.15-x86_64-3.8 creating build/temp.macosx-10.15-x86_64-3.8/src_c creating build/temp.macosx-10.15-x86_64-3.8/src_c/SDL_gfx clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -DENABLE_NEWBUF=1 -I/NEED_INC_PATH_FIX -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python@3.8/3.8.5/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src_c/gfxdraw.c -o build/temp.macosx-10.15-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 'clang' failed with exit status 1 ---------------------------------------- ERROR: Command errored out with exit status 1: /usr/local/opt/python@3.8/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/tmp/pip-install-l162cq0k/pygame/setup.py'"'"'; __file__='"'"'/private/tmp/pip-install-l162cq0k/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-ywey3qut/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.8/pygame Check the logs for full command output.
よく見てみると、エラーの中段に下記のような記載がある。
src_c/_pygame.h:216:10: fatal error: 'SDL.h' file not found #include <SDL.h> ^~~~~~~ 1 error generated.
これはpygame.hの216行目でSDL.hがincludeできなくてエラーになっていることがわかる。
つまり、SDL.hをインストールすれば良い。
対象方法
下記のコマンドでSDL.h関連のパッケージをインストールする。
$ brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
もう一度、pipコマンドを叩くと無事インストールできた。
$ sudo pip3 install pygame WARNING: The directory '/Users/okamotosatoki/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting pygame Downloading pygame-1.9.6.tar.gz (3.2 MB) |████████████████████████████████| 3.2 MB 2.7 MB/s Building wheels for collected packages: pygame Building wheel for pygame (setup.py) ... done Created wheel for pygame: filename=pygame-1.9.6-cp38-cp38-macosx_10_15_x86_64.whl size=2222212 sha256=8712112bcd6318e80395b05ca85b095acd8667899b16da526ecc08ecb29d3a87 Stored in directory: /private/tmp/pip-ephem-wheel-cache-2liurj4r/wheels/5c/3a/34/864e618a7e57b5df7cc5f1d1338aa43e7d566a4749a540c9b7 Successfully built pygame Installing collected packages: pygame
以上。
コメント