Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Pygame in Windows system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "how to install Pygame in the Windows system". In the daily operation, I believe that many people have doubts about how to install Pygame in the Windows system. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "how to install Pygame in the Windows system". Next, please follow the editor to study!

Pygame is a cross-platform Python module designed for electronic games, which can be used to manage graphics, animation and even sound. Based on SDL, it allows real-time electronic game development without being bound by low-level languages (such as machine language and assembly language). By using Pygame to deal with tasks such as drawing images on the screen, you do not have to consider many tedious and difficult coding work, but focus on the high-level logic of the program.

You can find the Windows installer that matches the version of Python you are running from the following three addresses:

Https://bitbucket.org/pygame/pygame/downloads/ (the Pygame project is hosted on the code-sharing site Bitbucket)

Http://www.pygame.org/download.shtml (Pygame official website)

Https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame (if the above two addresses cannot find a suitable installer, this is recommended)

If you download a .exe file, run it directly, and if you download a .whl file, you need to open a command window, change to the directory where the file is located, and use pip to run it:

First check whether the computer has pip installed, open the terminal window, and execute the following command:

one

> python-m pip-- version

If you output version information, it is installed:

one

> pip 18.1 from E:\ Python\ lib\ site-packages\ pip (python 3.6)

Otherwise, install pip, visit https://bootstrap.pypa.io/get-pip.py, save the file directly if the dialog box appears, and if the source code of get-pip.py appears, you need to create a new get-pip.py file, copy and paste the code into it, and run get-pip.py using the following command:

one

> python get-pip.py

After the installation is complete, you can use the command python-m pip-- version again to check whether pip has been successfully installed. After successfully installing pip, use the following command to install Pygame: (be sure to cd to the directory of the file you downloaded first)

one

> python-m pip install-- the name of the .whl file downloaded by user

The following message indicates that the installation was successful:

one

Successfully installed the version of Pygame you installed

For example, if my Python version is 3.6.5 Python 64-bit, you need to download pygame-1.9.4-cp36-cp36m-win_amd64.whl, save the file to your desktop, and install Pygame using the following command:

one

two

three

four

five

six

seven

eight

C:\ Users\ Lenovo > cd desktop

C:\ Users\ Lenovo\ Desktop > python-m pip install-- user pygame-1.9.4-cp36-cp36m-win_amd64.whl

Processing c:\ users\ lenovo\ desktop\ pygame-1.9.4-cp36-cp36m-win_amd64.whl

Installing collected packages: pygame

Successfully installed pygame-1.9.4

C:\ Users\ Lenovo > Desktop >

Check whether Pygame is installed successfully: enter import pygame in the IDLE of Python. If no error is reported, the installation is successful, and then enter pygame.ver to see the version number:

)

Possible problems:

Error report: xxxxxxxxxxxxxxxxxxxxxx.whl is not a supported wheel on this platform.

Reason: Python version does not correspond to Pygame version

Solution: the cp** in the Pygame file name represents the corresponding version of Python, and if it is not 64-bit on your computer, download 64-bit, depending on whether the Python you installed is 64-bit, pay attention to download the corresponding version!

Error report: You are using pip version x.x.x, however version x.x.x is available.You should consider upgrading via the 'python-m pip install-- upgrade pip' command.

Reason: version needs to be updated

Solution: enter the python-m pip install-- upgrade pip command to update

At this point, the study on "how to install Pygame in the Windows system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report