line of code try the following command
pip install pygame
Display the following error message
The first step is to find pygame on the website Archived: Python Extension Packages for Windows - Christoph Gohlke (uci.edu) .
The second step is to download the corresponding whl file according to the system and python version.
For example, my python version is 3.11, my computer is windows10, and I downloaded
pygame‑2.1.2‑cp311‑cp311‑win_amd64.whl
The 311 here probably means the version number 3.11
The third step is to transplant the downloaded whl file ctrl+x, ctrl+v to the computer desktop.
The fourth step is to open the cmd command line and execute the following command to install the wheel
pip install wheel
If you don't have pip, please install a pip first
The fifth step, enter the following command to switch to the desktop
cd desktop
The sixth step, because we have switched to the desktop in the fifth step, and we have moved the whl file to the desktop in the third step, now pip can directly operate on the whl file.
Enter the following command to install
pip install whl文件全名
For example, this file on my desktop is this
Then the command I need to enter is pip install pygame-2.1.2-cp311-cp311-win_amd64.whl
Remember that the suffix name cannot be missed
The installation is over here, if you are not at ease, you can open your python and try
import pygame
and run once
If no error is found, the installation must be successful.
--Thanks--
The solution comes from
Pip installs pygame in a python virtual environment and prompts an error
How to install the whl file downloaded by python_-Han-的博客-CSDN Blog_whl file installation