Cesar Augusto
Cesar Augusto

Reputation: 268

pygame installation via pip

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?

Upvotes: 1

Views: 2689

Answers (3)

Rasit aydin
Rasit aydin

Reputation: 469

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

Upvotes: 1

Lucas Emanuel
Lucas Emanuel

Reputation: 26

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

See Pygame GettingStarted

Upvotes: 1

Matin Hassan
Matin Hassan

Reputation: 11

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!

Upvotes: 1

Related Questions