How to uninstall pygame on mac OSX 10.9.4

2019-06-03 11:27发布

问题:

In fact, I meet the problem that my pygame can not load png image and the method pygame.image.get_extended() returns 0, which means false

Traceback (most recent call last):
  File "testpygame.py", line 5, in <module>
    myimage = pygame.image.load("diamond.png")
pygame.error: File is not a Windows BMP file

I search for solutions and some people suggest that installing the proper version of pygame might help, so I want to uninstall my current pygame and reinstall

But I dont know how to uninstall pygame on OSX

I installed 2 versions of python on mac (2.7 and 3.3), they are in the list of applications. But as we all know that the default python in mac that runs in terminal is another one given by the operating system itself, the different versions of python in mac totally confused me...

So, how can I uninstall pygame of the proper python version in my mac..? Thanks a lot

回答1:

I figure out the solution by finding my python's path in OSX, and delete the pygame library in site-package. My python's site-package's path is /Library/Python/2.7/site-packages, and I delete the pygame relevant folders here to uninstall pygame.

After I uninstall pygame and reinstall it, the problem that 'pygame.error: File is not a Windows BMP file' was also solved.



回答2:

Just wanted to add a quick correction to the path of pythons site package to the above mentioned answer - It should look something like this

" /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame"

I uninstalled pygame using pip & this is the output on the console.

pip uninstall pygame
Uninstalling pygame-1.9.1release:
  /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame
  /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame-1.9.1release-py2.7.egg-info
Proceed (y/n)? y
  Successfully uninstalled pygame-1.9.1release
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.


回答3:

My copy of pygame was installed via the disk image (.dmg) from this download page, which contains a package installer (.mpkg). You can attempt to uninstall the package, but that didn't work for me. Using the Suspicious Package app, I can look at the installer to see what it installs.

For the 1.9.1 version of Pygame, it installs the following:

/Developer/Python/pygame
/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pygame
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame-1.9.1release-py2.7.egg-info
/Library/Frameworks/SDL_image.framework
/Library/Frameworks/SDL_mixer.framework
/Library/Frameworks/SDL_ttf.framework
/Library/Frameworks/SDL.framework
/Library/Frameworks/smpeg.framework

You can manually delete all of these files to clear pygame from your system.

Note that Python.framework is where all user-installed versions of Python go to. If you are sure that you do not have a user-installed version of Python, you can delete it entirely. Otherwise, you should surgically remove the pygame parts as shown above.