Hi guys. I downloaded pygame and a few other modules for Python. I know that I have to put them in a certain folder to make sure Python can read them, but what is that exactly? I'm running a Mac, OS 10.6.6.
I already tried putting it in the main Python folder (with IDLE and Extras), and in the Extras folder.
Thanks,

JP

Recommended Answers

All 8 Replies

You can, of course put it anywhere and then update your PYTHONPATH to include it. Python packages on my mac live in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site_packages Beware that you may need to muck with one of the .pth files so the interpreter will correctly build its internal sys.path

edit: Somehow, at some point, I ended up with two Python.framework directories: One in /System/Library/Frameworks and the other as noted above. It was impossible to decide where to put packages; and the chaos was general. I eventually copied everything to the /Library/Frameworks/Python.framework location and placed a symbolic link in the /System/Library/Frameworks directory that referenced the real Python.framework location. That worked well.

Alright, I found the directory you speak of (the site_packages), and it still doesn't work.
I ran the site.py code just to make sure Python was looking in Site_packages, and it is.

https://docs.google.com/document/d/1SbNFoRvwuSzhlym3Y2NUo9yY1qHbB7YjSuA5-rIoK6E/edit?hl=en&authkey=COqV154L

These are two screenshots, one of IDLE after trying

import pygame

and then after running site.py.
The other is showing where I put pygame. Maybe I need to do somehow unpack pygame from its folder?

I don't do pygame, so my experience is not precisely germane. Look in your site-packages for a fie named *.pth that contains some reference to your pygame egg/folder/zip file (?). Can you add a line like the other lines that does the work (

A very quick Google search yielded this information, which I did not follow through. It does appear to be pretty straight forward.

edit: But you are using Python 3.x and pygame may or may not work with 3.1. Can I talk you into using Python 2.7?

You talked me into using Python 2.7.

So I got that, and there's no file in Site_Packages other than a readme.
Also, there aren't any files on my computer (According to Spotlight) that end in .pth.

So I get the sense that either something, somewhere went horribly wrong, or I'm just being an idiot and missing something obvious.

I figured "how hard could it be" and went to do it myself. Oops. Worked fine for 2.6, but no luck on 2.7. Spelunking around a little more, I found this:

I recently installed PyGame 1.9.1 on Mac OS X 10.6 (Snow Leopard) running Python 3.1 - check out the instructions at the bottom of this page: http://programming.itcarlow.ie/pygame.html - cheers, and good luck! (Paul Barry, Dec 2009).

... which eventually led me to this PDF... which was right after this: "[David has Pygame installed on his Mac OS X laptop - it took him the guts of an evening to get it installed. By that time, his hands were shaking and he had built up a bit of a sweat. But, Pygame was installed and working on Mac OS X]"
I'm not in the mood for shaking hands and sweated brow, so I'll leave you to it.

So I want to make sure I do this right:
Step 1: Download pygame-1.9.1release.tar.gz from the PyGame website and save
it to your disk - mine was saved into my Downloads folder. With the download
complete, open up a new Terminal window and type: cd Downloads
Ok thats pretty easy

Step 2: Issue tar zxvf pygame-1.9.1release.tar.gz to unpack the downloaded file.
As in, write that in Terminal and press enter?

Step 3: Change into the newly created directory: cd pygame-1.9.1release
I assume 'cd' is the terminal command for switching directories?
Step 4: Issue this command: python3 config.py

Step 5: Edit the newly-created Setup file changing this line (on my system it was line
72):
pypm src/pypm.c $(SDL) $(PORTMIDI) $(PORTTIME) $(DEBUG)
to look like this (note: addition of # at the start of the line):
# pypm src/pypm.c $(SDL) $(PORTMIDI) $(PORTTIME) $(DEBUG)
Be sure to exit and save the Setup file.

Step 6: From the command-line, issue this command (exactly as shown, all on the
one line):
export CC='/usr/bin/gcc-4.2' CFLAGS='-isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386'

Step 7: Build PyGame with this command: python3 setup.py build
Again, that's in Terminal?
This will take a while and you'll see a lot of stuff on screen (including a bunch of
warnings, which you can safely ignore). You only have to worry if you see the word
“error”.
Step 8: Install PyGame as follows: sudo python3 setup.py instal

So I want to make sure I do this right:
Step 1: Download pygame-1.9.1release.tar.gz from the PyGame website and save
it to your disk - mine was saved into my Downloads folder. With the download
complete, open up a new Terminal window and type: cd Downloads
Ok thats pretty easy

Step 2: Issue tar zxvf pygame-1.9.1release.tar.gz to unpack the downloaded file.
As in, write that in Terminal and press enter?

Step 3: Change into the newly created directory: cd pygame-1.9.1release
I assume 'cd' is the terminal command for switching directories?
Step 4: Issue this command: python3 config.py

Step 5: Edit the newly-created Setup file changing this line (on my system it was line
72):
pypm src/pypm.c $(SDL) $(PORTMIDI) $(PORTTIME) $(DEBUG)
to look like this (note: addition of # at the start of the line):
# pypm src/pypm.c $(SDL) $(PORTMIDI) $(PORTTIME) $(DEBUG)
Be sure to exit and save the Setup file.

Step 6: From the command-line, issue this command (exactly as shown, all on the
one line):
export CC='/usr/bin/gcc-4.2' CFLAGS='-isysroot /Developer/SDKs/MacOSX10.6.sdk -arch i386'

Step 7: Build PyGame with this command: python3 setup.py build
Again, that's in Terminal?
This will take a while and you'll see a lot of stuff on screen (including a bunch of
warnings, which you can safely ignore). You only have to worry if you see the word
“error”.
Step 8: Install PyGame as follows: sudo python3 setup.py instal

The answer is yes for all your questions in red.

Awesome, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.