mac下使用pip安装pygame包报错
2020-01-28 本文已影响0人
左木北鱼
报错1: xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
copying examples/oldalien.py -> build/lib.macosx-10.9-x86_64-3.8/pygame/examples
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
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
---
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/var/folders/6k/njbpvsgn0fs_40gfpmf8cq6r0000gn/T/pip-install-d86op3co/pygame/setup.py'"'"'; __file__='"'"'/private/var/folders/6k/njbpvsgn0fs_40gfpmf8cq6r0000gn/T/pip-install-d86op3co/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/var/folders/6k/njbpvsgn0fs_40gfpmf8cq6r0000gn/T/pip-record-cgqwlr68/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/pygame Check the logs for full command output.
解决1:xcode-select --install
报错2:src_c/_pygame.h:216:10: fatal error: 'SDL.h' file not found
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/var/folders/6k/njbpvsgn0fs_40gfpmf8cq6r0000gn/T/pip-install-bkcwavcf/pygame/setup.py'"'"'; __file__='"'"'/private/var/folders/6k/njbpvsgn0fs_40gfpmf8cq6r0000gn/T/pip-install-bkcwavcf/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/var/folders/6k/njbpvsgn0fs_40gfpmf8cq6r0000gn/T/pip-record-ls7p0o4d/install-record.txt --single-version-externally-managed --compile --install-headers /Library/Frameworks/Python.framework/Versions/3.8/include/python3.8/pygame Check the logs for full command output.
解决2:brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
最后安装正常:
pip install pygame -i https://mirrors.aliyun.com/pypi/simple/