0

I tried to install Pygame into my Ubuntu laptop. I opened the terminal and enetered : sudo apt-get install python-pygame Then after completing all the formalities I tried to use pygame in my python IDLE by typing: import pygame . But the Idle says that there is no module called pygame. I searched for answers and tried a lot of them but I didnt find an answer. Can anyone please help !...

  • 1
    You have installed pygame for Python 2 and not Python 3. Did you install IDLE for Python 2 or for Python 3? – edwinksl Jul 26 '16 at 18:04
  • Yes . In fact I have two IDLE's working on my laptop right now. One works with python2 and python3 – Pranav Nalam Jul 27 '16 at 2:24
  • Why don't you try invoking IDLE by running idle in your terminal and then try import pygame? – edwinksl Jul 27 '16 at 2:25
0

Fire up a terminal and run:

/usr/bin/python2
import pygame

If it doesn't give you any errors, you're good to go! You can then exit the interpreter with: CTRL+D

If it worked fine, that probably means you installed a custom version of Python that doesn't see the modules installed by apt-get.

  • It is not true that Python 3 is default; Python 2 is default. – edwinksl Jul 26 '16 at 18:00
  • @edwinksl - Updated. The source I read must have been wrong. – Android Dev Jul 26 '16 at 18:03
  • so what do i do right now?? – Pranav Nalam Jul 27 '16 at 2:27
0

You might need to get pygame for Python 3 To do this first install pip to install Python packages...

sudo apt-get install python3-pip

Then install pygame...

python3 -m pip install pygame

That should be it :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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