Mac安装pygame module

  1. 安装homedrew
    打开终端, 执行命令: /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
    Mac安装pygame module
  2. 安装pygame依赖: brew install hg sdl sdl_image sdl_ttf
  3. 安装pip - sudo easy_install pip
  4. pip install pygame (python 2.7, python3 需修改pip 到pip3)
  5. 但报如下错误:
    Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: ‘/Library/Python/2.7/site-packages/pygame’
    Consider using the --user option or check the permissions.
    所以用了 sudo pip install pygame命令 (root权限),但仍然报
    Could not install packages due to an EnvironmentError: [Errno 1] Operation not permitted: ‘/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pygame’
  6. 后又执行了 pip install --user pyspider执行,在执行pip install pygame,安装成功