Installation Process in Linux based on pygame module in python (detailed description), pythonpygame
1. Use pip to install the Python package
Most newer Python versions have their own pip, so you can first check whether the system has installed pip. In Python3, pip is sometimes called pip3.
1. Check whether pip is installed in Linux and OS X.
Open a terminal window and run the following command:
In Python2.7:
zhuzhu@zhuzhu-K53SJ:~$ pip --versionpip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
In Python3.X:
zhuzhu@zhuzhu-K53SJ:~$ pip3 --versionpip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
If not, install pip
Run the following command to install pip on the terminal:
sudo apt install python-pip
Run the following command to install pip3 in the terminal window:
Sudo apt install python3-pip
2. Install Pygame in Linux
If we are using Python2.7, use the Package Manager to install Pygame. to do this, open a terminal window and execute the following command. This will download Pygame and install it in our system:
$ sudo apt-get install python-pygame
If we are using Python3, we need to perform two steps: Install the library of Pygame dependencies; download and install Pygame.
Run the following command to install the library on which Pygame depends (replace the python3-dev with Python3.5-dev if we use Python3.5 when starting the terminal session ):
$ sudo apt-get install python3.5-dev mercurial$ sudo apt-get install libsdl-image1.2-dev libsdl2-dev libsdl-ttf2.0-dev
If you need to enable some advanced features of Pygame, such as adding sound, you can install the following additional libraries:
$ sudo apt-get install libsdl-mixer1.2-dev libportmidi-dev$ sudo apt-get install libswscale-dev libsmpeg-dev libavformat-dev libavcodec-dev$ sudo apt-get install python-numpy
Next, run the following command to install Pygame (replace pip with pip3 if necessary ):
hg clone https://bitbucket.org/pygame/pygame cd pygame python3 setup.py build sudo python3 setup.py instal
Or try $ pip install -- user hg + http://bitbucket.org/pygame/pygameif feasible
To confirm the installation is successful, start a Python terminal session and run the following command to import Pygame:
$ python3 >>> import pygame >>>
The above installation process in Linux based on the pygame module in python (detailed description) is all the content that I have shared with you. I hope to give you a reference and support for the help house.