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?
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, ie: /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
/Library/Python/2.7/site-packages/XXXX
being XXXX the folder where the pygame
package is. .pth
it in your python interpreter site-packages with the name externals
for instance. This means the full path must be: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/externals.pth
import pygame
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.