Question

[Solved] pygame error: “ImportError: No module named ‘pygame’”

This is my situation:

enter image description here

I tried importing pygame in both python 3.4.2 and python 3.6.3 using both pip and pip3 respectively.

In the python 3.4.2 shell:

Traceback (most recent call last) is:
File “”, line 1, in
import pygame
ImportError: No module named ‘pygame’

In the python 3.6.3 shell:

Traceback (most recent call last):
File “”, line 1, in
import pygame
File “C:Usersaditya dandAppDataLocalProgramsPythonPython36libsite-packagespygame__init__.py”, line 141, in
from pygame.base import *
ModuleNotFoundError: No module named ‘pygame.base’

Those are the errors that occurred.

I also used pygame-1.9.2a0-hg_5974ff8dae3c%2B.win32-py3.4.msi.
It’s showing the header’s file of pygame, but it’s not importing something.

What can I do to solve this?

Solution #1:

Step1:

check http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame to find a Windows installer that matches the version of Python you’re running.
The current version of pygame is : pygame-1.9.4-cp37-cp37m-win_amd64.whl

Move this file to the folder C:UsersusernameAppDataLocalProgramsPythonPython37Scripts

=========================================

Step2:

open cmdand then type:

cd
cd /d C:Windows
cd /d C:UsersusernameAppDataLocalProgramsPythonPython37Scripts

and then type the command:

pip install pygame

Now you have successfully installed pygame package.

=========================================

Step3:

open PyCharm File >> setting
make sure the “Project Interpreter” has the “pygame” package like the following:

File>>Setting>> make sure the “pygame” package is there.

Respondent: kimmi

Solution #2:

check if you have added python to path

Respondent: dragon445

Solution #3:

ans done if any one need help delete all python version from system and install python 3.5.2 from https://www.python.org/downloads/release/python-352/

then go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame

and search pygame and download pygame?1.9.3?cp35?cp35m?win_amd64.whl

then go to C:Users”your username”AppDataLocalProgramsPythonPython35Scripts> in this location in cmd ( command prompt )

type this line and done ” pip3 install pygame-1.9.3-cp35-cp35m-win_amd64.whl “

hope this help you

Respondent: Aditya Dand

Solution #4:

Edit – pygame only works in python >= 3.6.*

If you are using Windows i had the same problem and i know how to fix it, follow the steps:

  1. Go to the pygame website, then go to the downloads page
  2. Once there scroll down to the windows section and copy the bit that
    it says to put into pip It should start with py
  3. Once this short piece of code is copied, open command prompt (search
    it on start, it is nothing to do with python)
  4. Open it and paste the line of code, it should say downloading and
    then installing and just wait a bit for it to finish. Then in the
    command prompt paste the example.aliens thing in and it should work.
  5. Now the complicated part, open file explorer, go to this pc and
    search pygame once it has fully loaded, look near the top if the
    list of things it came up with. There should be 2 thing that are
    called pygame.
  6. Now leave this open and hold the windows button and press r
  7. Then type %appdata% and press enter
  8. This will open the appdata roming file

    Look at the bit at the top that says Appdata > roaming and click on
    app data

  9. Then click local, then programs, then python, then python36 then go
    to scripts
  10. Now go back to the pygame search. Click and drag the 2nd thing
    called pygame into the scripts folder
    and you should be good to go.

Pls comment if this doesnt make sense or you would like further
details

Respondent: Glitchd

Solution #5:

Did you install pygame? You need to type pip install pygame or sudo install pygame into terminal. If you are using windows 10, press the windows logo key then type terminal. You can check it’s installed with: pygame -H or pygame help

Respondent: Psychzander

Solution #6:

You can either use cmd to install pygame type this
pip install pygame (you have to make sure that python is installed)
If this doesn’t help
Use thonny idle I use it because python doesn’t work with my pc basically Thonny is a python idle which runs without the requirement of python to be installed and you can also install modules using thonny and type python code as well but make sure that if you import a module in thonny that module can be only used in thonny and can’t be used in any other idle unless you install it in cmd but you don’t need it as thonny idle is great so if you want to install modules like pygame in thonny 1) Open thonny 2) click on tools 3) click on open shell
There you can type pip install pygame and install it successfully I have a potato pc which can’t run python because it requires service pack 1 windows7 or above I don’t have it I only have windows 7 so I use thonny and use pygame using thonny only. 😀

Respondent: Forgan Dorgan

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy