Solved

Python - Where is pygame?

Posted on 2014-01-26
17
573 Views
Last Modified: 2014-01-29
Hi
I'm trying to start learning pygame.
With this simple code, even

it won't get past this

import sys, pygame
from pygame.locals import *

Open in new window


I get . . red error lines

>>> ================================ RESTART ================================
>>> 
Traceback (most recent call last):
  File "/Users/dominiquehancock/Documents/bouncinBall.py", line 1, in <module>
    import sys, pygame
ImportError: No module named 'pygame'
>>> 

Do I have to install pygame? How? It isn't a default module?

Thanks
0
Comment
Question by:beavoid
  • 9
  • 7
17 Comments
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39810142
Nope, pygame is not a default module for python.

You have to install it from here:  http://pygame.org/download.shtml

HTH,
Dan
0
 
LVL 88

Expert Comment

by:rindi
ID: 39810159
On 'nix based OS's, like debian or Fedora etc, you can usually use your distro's package manager to get it directly from the distro's repositories. For example in Debian you'd use synaptic to search for pygame, then install it, or you could also open a terminal as root user and enter

apt-get update
apt-get install python-pygame
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39810163
/Users/dominiquehancock/Documents/bouncinBall.py

I'm willing to bet the OP is on Windows...
0
 

Author Comment

by:beavoid
ID: 39810177
Mac OS 10.8

Also, are Python programs runnable from a browser? Do they have to be downloaded and installed first? Are they like java apps?
Thanks

Thanks
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39810217
Also, are Python programs runnable from a browser?
No, not by default. You can run Skulpt (http://www.skulpt.org/) if you want an in-browser python implementation.

Do they have to be downloaded and installed first?
No, the python programs are text files, that the python executable interprets and runs.
0
 

Author Comment

by:beavoid
ID: 39810326
So, people can inspect my game's code with impunity? And I can see how other games are made?
How are python programs / apps usually deployed? Does every computer need to install the python interpreter?
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39810333
No, you can create executables from your scripts, when you're ready to deploy. There are various tools for this: py2exe, pyInstaller, cx_Freeze etc.

HTH,
Dan
0
 

Author Comment

by:beavoid
ID: 39810443
Is my deployment platform independent?
It sounds like I have to anticipate various platforms. Surely the interpreter is like a JVM, and works everywhere?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39810449
The interpreter works anywhere.

The resulting programs, if you choose to compile them, no longer need the interpreter and are platform-dependent.
0
 

Author Comment

by:beavoid
ID: 39810703
Ok, thanks.

When I finish my cunning plan, I just compile a version for Windows, and Mac, and I should be good?
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39811060
Yup.
0
 

Author Comment

by:beavoid
ID: 39812260
Good.
Nobody can inspect my source once compiled. The .py no longer exists in any discernible way? What about a huge project, like a game, no problems with code size?
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39812289
All huge projects are made from smaller, manageable parts. Look into any game's folder and you'll see lots of files.

The source code is not accessible from the compiled exe.
0
 

Author Comment

by:beavoid
ID: 39813895
Status :
- I have IDLE working, can make .py programs.

- but, I still can't install pygame, because it requires "System Python 2.7")

Is System Python a separate entity from 3.3.3? Where is the best link to it?

Is pygame not happening for 3.3.3?
Thanks
0
 
LVL 34

Expert Comment

by:Dan Craciun
ID: 39814133
Like I said on your other question (Q_28349483), pygame has not been officially ported to Python 3.

HTH,
Dan
0
 

Author Comment

by:beavoid
ID: 39815031
Sorry, my bad.

Thinking...

My project can initially be a circles and squares demo. Is Tkinter capable of decent frame drawing / updates for an unpolished demo version of a complex system? (RTS client)

I saw that Python can do datagrams fine, so for an RTS, I am ready to get cracking, tho it may be wise to do a server in Java.

Could I get by with TKinter until Pygame is updated?

Thanks
0
 
LVL 34

Accepted Solution

by:
Dan Craciun earned 500 total points
ID: 39815107
I have no idea on what the speeds of TKinter are.

Some resources:
- Video: Game Development Fundamentals with Python: https://www.udemy.com/game-development-fundamentals-with-python/
- Books: Invent Your Own Computer Games with Python and Making Games with Python & Pygame: http://inventwithpython.com/
- games written in Python (with sources): http://www.pyweek.org/
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
firstChar challenge 13 110
Scripting vs. Programming languages 25 151
Python On Mouseover Save URL/Link 4 59
Q2. How to run DAX query from SSMS. I don’t see any DAX query type. 1 48
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now