Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyGame] Getting started
#1
Dear Forum,

I am having trouble getting started. I just downloaded and installed pygame, but I can't initialize it.

Here is my code:

import pygame
pygame.init()

and here is my error message.

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
pygame.init()
AttributeError: module 'pygame' has no attribute 'init'

I am using python 3.5.2 and pygame 1.9.2.a0.win32-py2.7

Thanks.
Reply
#2
Did you name another file or directory pygame where you are running this file?
Recommended Tutorials:
Reply
#3
1. You should have matching pygame version to python.
pygame 1.9.2.a0.win32-py2.7 stand for python 2.7.
I believe python 3.3 and above don't have a specific version.

2. Learn to use python pip.
use pip to install pygame. you might need admin rights.
pip install pygame
or
python -m pip install pygame
99 percent of computer problems exists between chair and keyboard.
Reply
#4
Good catch...i must of not even saw the wheel name
Recommended Tutorials:
Reply
#5
Dear metulburr and Windspar,

Thank you for your replies. Here is a newbie of all newbies question:

Is pip already part of the Python version that I downloaded? (python 3.5.2. I've also downloaded 3.6.4, too.)

Do I type "pip install pygame" or "python -m pip install pygame" into the
Python shell? on Windows command propmt? in a saved python file? I've tried all different variations.

Is there a tutorial that you can link me to that can explain things to a newcomer? I've looked at the pygame wiki and I think it assumes I know more than I do. (https://www.pygame.org/wiki/GettingStarted)
Reply
#6
OK. I think I got it by using the Windows command prompt and the first demo program worked. Thank you to metulburr and Windspar for your help.
Reply
#7
(Feb-21-2018, 06:57 AM)goofymdjd Wrote: Do I type "pip install pygame" or "python -m pip install pygame" into the
Python shell? on Windows command propmt? in a saved python file?
For future searchers....

Pip install pygame assumes you have navigated to the scripts directory in python location you installed omitting the .py OR have added python to the PATH. Which python gives the option to in the installer.

Python -m pip install pygame invokes the pip to whatever the version is of 'python'. You can easily choose which python version you want to install the library to if you have numerous python versions.

Both of these are system commands in the windows command prompt. They both assume python and/or pip is in the PATH.
Recommended Tutorials:
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020