python - 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, Pillow
了conda
.
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)
解决方案
推荐阅读
- c# - 保存在 txt 文件中后,“unprotect”功能的字节无效
- azure - 托管开发人员门户未显示 API 信息
- java - 我如何制作子弹的旋转图案。(爪哇)
- flutter - 如何在flutter中查看模拟器ui中的元素
- javascript - 元素重复时如何将节点树合并为一棵
- unix - 如何在没有任何插件或工具的情况下使用 Unix 命令将 .xls 或 .xlxs 文件转换为 csv 文件
- python - 使用 Selenium 和 Python 单击网页上的按钮
- javascript - Javascript 解释器如何执行递归函数?
- scheme - 以 * 为后缀的方案名称
- laravel - Laravel 应用程序冻结不再响应