Problem description

When using Pygame on MacOS Mojave, I found that I can’t fill in the color and the page is blank.

Run the following code. If the page is blank or black, there is a problem.

python -m pygame.examples.aliens
Copy the code

Question why

Refer to Github Issues, the problem is at Homebrew. The SDL inventory through its installation is in question.

The solution

  • System demoted to Mojave version below. Is not recommended.
  • Install the Miniconda virtual environment to run PyGame. Complex, not recommended.
  • Download the latest Python package from the official website to replace the Homebrew version. Run the installation again
pip3 install pygame
Copy the code

You are advised to use this method.

It is recommended to use domestic address mirrors.sohu.com/python/3.7….

note

  • There is no need to uninstall Homebrew’s Python if you want to reinstall Python. Python3 in/usr/local/bin and pip3 soft links will be official installer replace with/Library/Frameworks/Python. The framework /… /usr/local/Cellar/… . The two versions can be switched at any time. The brew doctor command will prompt Warning, but don’t worry.

Refer to the link

  • Pygame not compatible with MacOS Mojave
  • Pygame 1.9.5 on the Mac, opens Windows, sets Caption, but will not draw or fill
  • SDL MacOS Mojave 10.4 black screen.
  • Python MAC runs PyGame blank without displaying content – Solution
  • Compatibility issues with Pygame and macOS, page blank