〇、前情提要
mac os catalina
python 3.7.3
在本方法前尝试过n³种方法安装pygame无果,但后来回想可能是连接断了的问题,纵观各种方法,用homebrew+pip3+install最佳。
一、安装homebrew
terminal中输入
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
- 如果出现curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to raw.githubusercontent.com:443 问题
请换手机热点尝试,或者翻个q
按提示安装:
二、升级pip
pip3 install --upgrade pip
直到进度条到100%
- 出现time out情况就再试几次
只要不断尝试总能成功的(我试了七次 真的是玄学了)
三、安装Pygame
pip3 install pygame
希望有玄学保佑⁄(⁄ ⁄•⁄ω⁄•⁄ ⁄)⁄(这次我试了14次)
四、测试Pygame
此处代码来自Python-100-Days-master
from enum import Enum, unique
from math import sqrt
from random import randint
import pygame
@unique
class Color(Enum):
"""颜色"""
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GRAY = (242, 242, 242)
@staticmethod
def random_color():
"""获得随机颜色"