Reputation: 1273
I just downloaded Pygame but I'm not sure how to import it into my program.
Where do I put the folder that contains Pygame? Within the python2.7 folder?
Upvotes: 1
Views: 639
Reputation: 37259
I took a look at the Pygame download instructions and it seems like the downloadable .exe
should probably take care of the nitty-gritty for you. Do you see a setup.py
file in the directory after you run the .exe
? If so, you should be able to run python setup.py install
from that directory to have it 'properly' installed (note: I've never used the installer, so it may very well bypass that step completely).
As far as where you would need put any given module, it's basically like @Adrian says - it's all where you want to put it. @tijko's post will show you exactly where Python looks when you use the import
statement.
Upvotes: 0
Reputation: 137350
Read the documentation:
Windows Binary Installer
This is probably the most popular method of installation. If you are running on windows, it is highly recommended you use this form of installing. The installers come with with nearly everything you need, and have an easy point and click installers.
...
So basically download version for Windows and it should be very easy to install (includes a wizard).
When it comes to importing, this is as simple as importing any other module:
import some_module
Specifically, PyGame can be imported like that (see tutorials):
import pygame
from pygame.locals import *
This should work, as the installer should make sure the module is on the path Python is searching for the modules. To see where exactly Python searches for modules, do this in the console:
import sys
print sys.path
If PyGame was installed on one of these paths, then everything should be okay.
Upvotes: 1
Reputation: 692
you can place the lib any where you like.
you may need to see this tutorial: http://docs.python.org/tutorial/modules.html
Upvotes: 0
Reputation: 8292
Start python, import sys, and print out sys.path. That's the search path that Python uses to find imports. You would normally put it in dst_packages.
import sys
print sys.path
From there you can see where python is looking.
I'm sure you could always go with a 'pip' install as well.
Do you have an error message you are receiving?
Upvotes: 0
Reputation: 2875
It all depends on where you want to put it. Python can be told to search for and load modules from any location you want, so long as you have read permissions. See the python documentation on Modules, particularly the section on the module search path.
The Pygame modules could, for ease of use, be placed in the same directory you're executing your python script from, or alternately your script could append the libraries path as directed in the above link, and then try to import the module(s) as appropriate.
Upvotes: 1