1

I'm trying to install pygame in my python 2.7. I do it in this python because for some reason if I try to install pip in python 3.7 it won't work. From the terminal I entered:

sudo pip install pygame

And supposedly I installed it well, but when I try to do the import it tells me:

Traceback (most recent call last):
  File "example.py", line 1, in <module>
    import pygame
ImportError: No module named pygame

if i try to do again sudo pip install pygame :

Requirement already satisfied: pygame in /home/cesar/.local/lib/python2.7/site-packages (1.9.4)

Also, if I try to run pip list and look for pygame, it appears that the module is already installed:

pygame                        1.9.4   

What may be happening? Why does python say that the requirement is already met if it is not able to import the module?

martineau
  • 119,623
  • 25
  • 170
  • 301
Cesar Augusto
  • 268
  • 4
  • 16

3 Answers3

1

Hmm.. My suggestion would be,

Go on this website : https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

Delete the current vesion of PyGame (.9.4) and follow the instructions on this video that I found for you on YouTube:

https://www.youtube.com/watch?v=vGb5EX3XjdI

This will give you a tutorial of how to install PyGame 1.9.3 a lower version.

Good luck!

1

Try python3 -m pip install -U pygame --user

See Pygame GettingStarted

1

Are u using python 2.7.x or 3.x when runing script ?

Possibly, You run command like

python3 example.py

Or you run python example.py but python --version is outputting 3.x version if you are using Windows.

Can you try install pygame with pip3 ?

pip3 install pygame
Rasit aydin
  • 419
  • 2
  • 6
  • 16
  • 2
    If I try to install with pip3 says: Requirement already satisfied: pygame in /home/cesar/.local/lib/python3.7/site-packages (1.9.4) I tryed run the script with python3 (which it runs python3.7) and python (which it runs python 2.7) – Cesar Augusto Sep 19 '18 at 21:02
  • Hıms, I tried in my system and worked perfectly. Can you try, pip3 uninstall pygame, pip3 install pygame, python3 example.py, – Rasit aydin Sep 19 '18 at 21:08
  • It says "Skipping pygame as it is not installed." In the second try of pip3 uninstall pygame but when I try: pip3 install pygame then says: Requirement already satisfied: pygame in /home/cesar/.local/lib/python3.7/site-packages (1.9.4) – Cesar Augusto Sep 19 '18 at 21:25