0

At first the version of pygame i downloaded was: pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3

then i got the error message when i run the program :

The function `CGSFlushWindow' is obsolete and will be removed in an upcoming update.

so i adopt the suggestion from Mac OS Pygame using a deprecated function CGSFlushWindow,

then i downloaded the new version which is here.

but now, a new following error comes:

Traceback (most recent call last):
  File "/Users/Crayon_277/Develop/Project/Pygame/my_pygame/my_pygame.py", line 3, in     <module>
    import pygame
ImportError: No module named pygame

i notice that the pygame package is in this directory (A) : /Library/Python/2.7/site-packages not this (B) : /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

so i try to copy it from A to B, but it doesn't work.

someone reminds me that i should see if sys.path contains pygame. and the answer is YES when i check it out.

so what i should do now? Can someone help me out?

1 Answer 1

2

Your problem is that your python interpreter can't find the pygame package. This is because you don't have the pygame package in the site-packages of the interpreter you are using.

You can probably fix that with an egg-link file in the site-packages of the python interpreter you are actually using. An egg-link file is a plain text file with a path inside, pointing to the place the real egg should be.

It could be something like this:

/Library/Python/2.7/site-packages/pygame

And just store it as pygame.egg-link, within your interpreter site-packages, i.e.: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

You can also do this with a .pth file. A .pth file is "kind of" the same, with directory paths that should be searched for packages as well. Create one, (give it a descriptive name), store it in the site-packages and you are good to go.

STEP BY STEP

  • Create a plain text file
  • Write the following line inside /Library/Python/2.7/site-packages/XXXX being XXXX the folder where the pygame package is.
  • Save the .pth it in your python interpreter site-packages with the name externalsfor instance. This means the full path must be: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/externals.pth
  • Run your python interpreter and import pygame
4
  • 1
    Sorry ,i'm a cookie. i've no idea what u're talking about.So ,where is the egg-link file? Am i going to make this a new file or..? Apr 11, 2014 at 7:29
  • I added a TODO list in my answer, check it out.
    – bgusach
    Apr 11, 2014 at 7:35
  • how can i save it as .pth file? i switch to plaintext and i did rename the file externals.pth as finder show to me. but it's been externals.pth.txt when i check it in pycharm . As result ,it also says import error ether in pycharm or IDLE Apr 11, 2014 at 7:51
  • You can't really expect that we solve all your problems. If you can't change a file's extension, google it.
    – bgusach
    Apr 11, 2014 at 8:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.