如何在mac OSX 10.9.4上卸载pygame
其实,我遇到了一个问题,我的pygame无法加载png图片,而且方法pygame.image.get_extended()返回的是0,这意味着出错了。
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
我搜索了一些解决办法,有人建议安装合适版本的pygame可能会有帮助,所以我想先卸载我现在的pygame,然后再重新安装。
但是我不知道在OSX上怎么卸载pygame。
我在Mac上安装了两个版本的Python(2.7和3.3),它们在应用程序列表里。但是大家都知道,Mac自带的终端运行的默认Python是操作系统自带的那个,这让我对Mac上的不同Python版本感到很困惑……
那么,我该怎么卸载我Mac上合适版本的pygame呢?非常感谢!
3 个回答
我安装的pygame是通过从这个下载页面下载的磁盘镜像文件(.dmg)来安装的,里面有一个包安装程序(.mpkg)。你可以尝试卸载这个包,但对我来说没用。我使用了Suspicious Package这个应用程序,可以查看安装程序到底安装了什么。
对于Pygame的1.9.1版本,它安装了以下内容:
/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
你可以手动删除这些文件,以便从你的系统中清除pygame。
需要注意的是,Python.framework
是所有用户安装的Python版本的存放位置。如果你确定自己没有安装过用户版本的Python,可以直接删除它。否则,你应该像上面所示的那样,仔细删除pygame的相关部分。
我想给上面提到的答案补充一下,关于Python的库文件路径的更正 - 它应该是这样的:
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pygame"
我用pip卸载了pygame,控制台上显示的是这个。
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.
我找到了解决办法,首先在我的Mac电脑上找到了Python的路径,然后在site-package文件夹里删除了pygame这个库。我的Python的site-package路径是/Library/Python/2.7/site-packages,我在这里删除了和pygame相关的文件夹,这样就卸载了pygame。
在我卸载pygame并重新安装后,之前出现的“pygame.error: 文件不是Windows BMP文件”的问题也解决了。