Installing pygame in linux

Pygame on Ubuntu Python 3

To install python3-pygame in Ubuntu 19.04 and later open the terminal and type:

sudo apt install python3-pygame 

Ubuntu 18.10

To install python3-pygame in Ubuntu 18.10 open the terminal and type:

sudo nano /etc/apt/sources.list 

Add this line to sources.list.

deb http://archive.ubuntu.com/ubuntu/ cosmic-proposed universe

Save sources.list with the keyboard combination Ctrl + O and press Enter and exit with Ctrl + X

Update the list of available software and install python3-pygame.

sudo apt update sudo apt install python3-pygame 

Ubuntu 16.04-18.04

sudo apt install python3-setuptools sudo easy_install3 pip python3 -m pip install --user pygame 

The pygame package on Ubuntu is only for python 2.7, so it is impossible to import if you use python 3. If you want python 3.x support, you need to install pygame 1.9.2 which is located at https://bitbucket.org/pygame/pygame/downloads

If you have all the dependencies installed, it should be as simple as running setup.py

I’m at a Pop-OS 20.04 machine and all of those answers didn’t work for me (◉_◉). So I went to the documentation of Pygame and realized that I had to have the dependencies installed. To do that you can:

sudo apt-get install git python3-dev python3-setuptools python3-numpy python3-opengl \ libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev \ libsdl1.2-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev \ libtiff5-dev libx11-6 libx11-dev fluid-soundfont-gm timgm6mb-soundfont \ xfonts-base xfonts-100dpi xfonts-75dpi xfonts-cyrillic fontconfig fonts-freefont-ttf libfreetype6-dev 

Now you are ready to install Pygame, so git clone their GitHub repository into your current folder and pip install the module:

git clone https://github.com/pygame/pygame.git 

Источник

Читайте также:  Tp link wireless adapter driver linux

How To Install python-pygame on Ubuntu 20.04

In this tutorial we learn how to install python-pygame on Ubuntu 20.04.

What is python-pygame

A multimedia development kit for Python. Pygame provides modules for you to access the video display, play sounds, track time, read the mouse and joystick, control the CD player, render true type fonts and more. It does this using mainly the cross-platform SDL library, a lightweight wrapper to OS-specific APIs.

This is the Python 2 version of the package. Description-md5: 80ac041c0e2b6ef31512e78313fa1d83

There are three ways to install python-pygame on Ubuntu 20.04. We can use apt-get , apt and aptitude . In the following sections we will describe each method. You can choose one of them.

Install python-pygame Using apt-get

Update apt database with apt-get using the following command.

After updating apt database, We can install python-pygame using apt-get by running the following command:

sudo apt-get -y install python-pygame 

Install python-pygame Using apt

Update apt database with apt using the following command.

After updating apt database, We can install python-pygame using apt by running the following command:

sudo apt -y install python-pygame 

Install python-pygame Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Ubuntu. Update apt database with aptitude using the following command.

After updating apt database, We can install python-pygame using aptitude by running the following command:

sudo aptitude -y install python-pygame 

How To Uninstall python-pygame on Ubuntu 20.04

To uninstall only the python-pygame package we can use the following command:

sudo apt-get remove python-pygame 

Uninstall python-pygame And Its Dependencies

To uninstall python-pygame and its dependencies that are no longer needed by Ubuntu 20.04, we can use the command below:

sudo apt-get -y autoremove python-pygame 

Remove python-pygame Configurations and Data

To remove python-pygame configuration and data from Ubuntu 20.04 we can use the following command:

sudo apt-get -y purge python-pygame 

Remove python-pygame configuration, data, and all of its dependencies

We can use the following command to remove python-pygame configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge python-pygame 

References

Summary

In this tutorial we learn how to install python-pygame package on Ubuntu 20.04 using different package management tools: apt, apt-get and aptitude.

Читайте также:  Самые лучшие версии linux

Источник

How to install pygame?

I am running Ubuntu 13.10. I have python 2.7.5 with anaconda 1.8.0. Whenever I start python and type import pygame it tells me that there is no module named pygame. How can I install pygame?

yeah,I did not look at the version no. properly.I typed in 13.04 but it was actually 12.04.I upgraded it and it worked!

5 Answers 5

The reason you are not able to import pygame into your python interpreter is because you are installing it for python2 and starting the python3 interpreter(Ubuntu 13.10 uses python3 by default).

To install pygame for python2(your version is 2.7.5), do this on a terminal( Ctrl + Alt + t ):

sudo apt-get install python-pygame 

and then start the python2 interpreter

and then try to import pygame as

To set python2 as your default interpreter, you can set an alias in your bash_aliases file. To do this, open a terminal and type:

This may open an empty file, depending upon whether you have set an alias before and then type

Do not change symlinks in /usr/bin/python3 , since this may break many application in Ubuntu 13.10 which use python3 vociriferously.

@saisanjeev: Either accept the answer as it helped you(if it did), else please post the answer that helped you and mark as accepted.

Note, to install pygame in python3 you have to build it from the source code. Following the simple instructions here (askubuntu.com/a/406410/327339), plus installing the one extra dependency before building (see my comment below the answer), worked for me in Xubuntu 16.04 LTS with Python 3.5.2.

Читайте также:  От чего имени запущен процесс linux

This should install pygame for python 3, as python3-pip is required for pygame.

 sudo apt-get install python3-pip python3-dev sudo pip3 install pygame 

I can confirm Jobin’s suggestion in his comment:

sudo apt-get install python-pygame 

Works flawlessly. Tested on 13.10.

Next time if you want to install a python package you can search whether it is in the repositories by running:

Then you can see the packages (if they are in the repositories) and their names. The output for apt-cache search pygame is

lightyears - single player real-time strategy game with steampunk sci-fi psychopy - environment for creating psychology stimuli in Python pyntor - flexible and componentized presentation program python-pygame - SDL bindings for games development in Python python-pyglet - cross-platform windowing and multimedia library python-soya - high level 3D engine for Python python-soya-dbg - high level 3D engine for Python - debug extension python-soya-doc - high level 3D engine for Python solarwolf - Collect the boxes and don't become mad 

In this list you can select the package (here: python-pygame ) and run sudo apt-get install the-package-name .

For more debugging of dependencies see Installing pygame with pip.

Источник

Оцените статью
Adblock
detector