Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Did you try using sudo apt-get install python-pygame? – i08in Jan 4 '14 at 6:36
yes,i did try it – saisanjeev Jan 4 '14 at 9:53
Were any of the answers helpful? – i08in Feb 13 '14 at 20:12
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! – saisanjeev Feb 16 '14 at 11:47
up vote 10 down vote accepted

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

import pygame

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:

nano ~/.bash_aliases

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

alias python='python2'

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

share|improve this answer
I use python with anaconda 1.8.0.So whenever I start python,it starts with anaconda – saisanjeev Jan 5 '14 at 9:41
got it thanks everyone and special thanks to you Jobin. – saisanjeev Jan 6 '14 at 5:25
@saisanjeev: Either accept the answer as it helped you(if it did), else please post the answer that helped you and mark as accepted. – i08in Jan 6 '14 at 8:42

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:

apt-cache search pygame

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.

share|improve this answer
yeah,it's the same thing i get.But,when i type 'python' in the Terminator or terminal,I get this:-'Python 2.7.6 |Anaconda 1.8.0 (32-bit)| (default, Nov 11 2013, 10:47:19) [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux2 Type "help", "copyright", "credits" or "license" for more information.'Then after the 3 arrows, I typed :'import pygame' and it showed this error:-'Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named pygame'.Why is this so?Maybe because i use anaconda python? – saisanjeev Jan 4 '14 at 9:59
I don't see why that would be the problem. Are you typing 'import pygame' or import pygame (without the '')? – don.joey Jan 4 '14 at 10:03
I am typing just 'import pygame' – saisanjeev Jan 5 '14 at 9:47
I feel its because i have anaconda 1.8.0 – saisanjeev Jan 5 '14 at 9:48
Thanks.I got it. – saisanjeev Jan 6 '14 at 5:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.