0

I usually work with Unity, but today I decided to give pygame another go to improve my python skills. In MacOSX terminal, I installed pygame like so: $ pip3 install pygame, and everything works. Then I decided to test its functionality by quickly hopping into python in terminal: $ python3. Then imported it:

>>> import pygame

everything worked. Then, in my project, I was importing some of the standard modules I knew I would need:

import time
import pygame
import random
import os

and it said, after running, that the module pygame was not installed. Since I'm on Mac, python 2.7 is pre-installed and I might have installed pygame in the 2.7 directory, but I checked it all out and nothing seems to be wrong. Please help me install pygame! Thanks

lrainey6-eng
  • 183
  • 1
  • 1
  • 8
  • 1
    Using `pip3` installs the module for Python3. It seems that when you launch your script you're probably using Python2. Try `python3 – import random Dec 02 '20 at 00:44
  • Yes this works, and this is why I've been using the terminal to run python recently, but it would be much more convenient to run the code from sublime text, which you do by pressing `cmnd` + `B`, but this calls the error in the title. When I tried to install through IDLE, it said that it was already installed. I'll try running my code in IDLE and see if that works – lrainey6-eng Dec 02 '20 at 17:59

1 Answers1

0

If yours is a recent version of MAC OS X try this:

python3 -m pip install -U pygame --user
Vidya Ganesh
  • 788
  • 11
  • 24
  • I don't know why this is, but it doesn't work: `no such option: --levinrainey` (the user name is `levinrainey`, I double checked this by using `ls` in the `/Users` directory) – lrainey6-eng Dec 02 '20 at 18:06