0

I've downloaded pygame version 2.1.2 and I'm using it with python 3.10.4 but it is giving an error when I try to import it:

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import pygame
ModuleNotFoundError: No module named 'pygame'

I have tried it on vscode and it was working but it suddenly isn't working anymore. Any suggestions please?

Javad
  • 2,033
  • 3
  • 13
  • 23
Vicky B
  • 11
  • 1
  • 2
  • 1
    You said it was working and now it isn't working anymore. Did I get that correct? Maybe you have different Python versions on your computer and now you try to run your code with a Python version where PyGame isn't installed. – Matthias May 12 '22 at 12:39
  • Have you installed that on a virtual environment before? – Javad May 12 '22 at 12:45
  • It is working now. I'm still not sure what happened but thanks for the suggestions – Vicky B May 13 '22 at 13:04

1 Answers1

1

Did you try install with pip like this: python -m pip install pygame?

Maybe you can find more answers on this page: ImportError: No module named 'pygame'

SamBjork
  • 25
  • 5
  • Just for the case of you are using virtualenv than it must be activated if you installed it in such place. like # make the venv call it venv python3 -m venv venv # just checking what is there in global scope for pip3 pip3 list # activate your local venv source venv/bin/activate # show local venv scope pip3 list than you could basicly install whatever you need in different versions... ;) – Christoph Schwalbe May 12 '22 at 12:47