0

I am trying to install and use pygame on macOS through IDLE. I have used the pip install pygame command and the terminal says that pygame is installed on my computer. However, whenever I use "import pygame" I get an error that says:

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

How do I fix this? I am running python version 3.9.7 and the pygame I have installed is version 2.1.2

jkrue242
  • 1
  • 3
  • 1
    MacOS comes with both Python 2 and Python 3. Your `pip` might be going to Python 2. Do `python -m pip install pygame`. – Tim Roberts Feb 07 '22 at 04:53
  • Are you using a virtual enviroent? If not I highly recommend it, just create a new one and install pygame there. Of course you should take a look at Tim Roberts comment first – M. Villanueva Feb 07 '22 at 05:40
  • On mac, `python` likely refers to python2, so it would need to be `python3 -m pip install pygame` – Starbuck5 Feb 07 '22 at 06:27
  • If you type `python --version` in the terminal, this will tell you if `python` is 2 or 3. – Jack Deeth Feb 07 '22 at 15:19

0 Answers0