- 需要先安装pygame的依赖库
brew install hg sdl sdl_image sdl_ttf
否则会出现一下错误
ERROR: Command errored out with exit status 1:
command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/vk/0t65zzl52rv33vpdmlhqtlhm0000gn/T/pip-req-build-k_jxu97j/setup.py'"'"'; __file__='"'"'/private/var/folders/vk/0t65zzl52rv33vpdmlhqtlhm0000gn/T/pip-req-build-k_jxu97j/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/vk/0t65zzl52rv33vpdmlhqtlhm0000gn/T/pip-pip-egg-info-13one4uv
cwd: /private/var/folders/vk/0t65zzl52rv33vpdmlhqtlhm0000gn/T/pip-req-build-k_jxu97j/
Complete output (27 lines):
WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using Darwin configuration...
/bin/sh: sdl2-config: command not found
/bin/sh: sdl2-config: command not found
/bin/sh: sdl2-config: command not found
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/vk/0t65zzl52rv33vpdmlhqtlhm0000gn/T/pip-req-build-k_jxu97j/setup.py", line 306, in
buildconfig.config.main(AUTO_CONFIG)
File "/private/var/folders/vk/0t65zzl52rv33vpdmlhqtlhm0000gn/T/pip-req-build-k_jxu97j/buildconfig/config.py", line 221, in main
deps = CFG.main(**kwds)
File "/private/var/folders/vk/0t65zzl52rv33vpdmlhqtlhm0000gn/T/pip-req-build-k_jxu97j/buildconfig/config_darwin.py", line 131, in main
[DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl'])],
File "/private/var/folders/vk/0t65zzl52rv33vpdmlhqtlhm0000gn/T/pip-req-build-k_jxu97j/buildconfig/config_unix.py", line 39, in __init__
self.ver = config[0].strip()
IndexError: list index out of range
---
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 errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
- 如果要启用Pygame的更高级功能,如游戏中包含声音,还需要安装以下库
brew install sdl_mixer portmidi
- 接下来安装pygame
pip3 install pygame
默认安装的是当前发布的正式版本(1.9.6),但是在mac10.15上无法跑起来(可能之前的几个版本也跑不起来)
需要安装2.0的开发版
pip3 install pygame==2.0.0.dev10(最新的,也可以安装dev6)
网友评论