首页 > 解决方案 > Mac OSX 中 Pygams 中的 Windows BMP 文件错误

问题描述

我有一个基本的问题pygame。我想加载包教程中给出的简单图像。

import pygame
catImg = pygame.image.load('cat.png')

并得到以下错误:

error: File is not a Windows BMP file   

我看到这个问题被问了无数次,并给出了重新安装pygame和安装映像包 ( PIL, Pillow) 的答案。我尝试了所有这些,但仍然无法正常工作。到现在我已经重新安装了很多次pygame,它仍然不支持更多格式。

>>pygame.image.get_extended()
>> 0

我在用Python 2.7.14 |Anaconda custom (64-bit)| (default, Oct 5 2017, 02:28:52)

我安装PIL, Pillowconda.

OSX 是Mac OSX High Sierra 10.13.14.

$type python
python is hashed (/Users/username/anaconda2/bin/python)

我只是这样做:

$ python
Python 2.7.14 |Anaconda custom (64-bit)| (default, Oct  5 2017, 02:28:52) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
>>> pygame.image.load('cat.png')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pygame.error: File is not a Windows BMP file

或者做同样的事情,jupyter结果是一样的。

$ python -V
Python 2.7.14 :: Anaconda custom (64-bit)

标签: pythonpygame

解决方案


推荐阅读