使用PIL时,创建某个字体Font对象时出错:

font=ImageFont.truetype('Arial.ttf',36)

可能原因有两个:

1、PIL无法定位到字体文件的位置。

可以通过提供绝对路径解决,比如

font=ImageFont.truetype('C:\Windows\Fonts\Arial.ttf',36)

2、文件名写错了

font=ImageFont.truetype('arial.ttf',36)

一般情况下是第二种

PIL-ImageFont:OSError: cannot open resource的更多相关文章

  1. OSError: cannot open resource(pillow错误处理)

    https://www.jianshu.com/p/c64ae3e9b196 pillow使用备忘之OSError: cannot open resource错误处理 在使用pillow过程中,Pyt ...

  2. captcha库报错"OSError: cannot open resource"

    问题描述 在win平台上python虚拟环境下使用captcha库生成验证码报错OSError: cannot open resource 代码 from captcha.image import I ...

  3. python-----贴图 和 报错:OSError: image file is truncated (8 bytes not processed)的处理

    将一张图片贴到另一张图片上,代码如下: from PIL import Image import os from PIL import ImageFile ImageFile.LOAD_TRUNCAT ...

  4. Django报错:OSError: raw write() returned invalid length 4 (should have been between 0 and 2)

    在使用Django时Django报错:Django报错:OSError: raw write() returned invalid length 4 (should have been between ...

  5. 在python中使用print()时,raw write()返回无效的长度:OSError: raw write() returned invalid length 254 (should have been between 0 and 127)

    写出一个不是code的bug,很烦恼,解决了挺长时间,都翻到外文来看,不过还是解决了,只尝试了一种简单可观的方法,希望对大家有用 我正在使用Django与Keras(tensorflow)来训练一个模 ...

  6. ionic报错: Failed to load resource

    隔了一天,才发现是代码写错了 出错的原因是在ts 文件中使用这样的定义 data: [] = ['高新区', '经开区', '其他园区']; 错误在于这个定义的类型,不能是 [],修改成 any就没有 ...

  7. 黄聪:AngularJS中的$resource使用与Restful资源交互(转)

    原文:http://blog.csdn.net/he90227/article/details/50525836 1.AngularJS中的 $resource 这个服务可以创建一个资源对象,我们可以 ...

  8. 【c3p0】报错:java.io.FileNotFoundException: Resource not found at path '/mchange-log.properties'

    配置项目启动初始,报错如下: java.io.FileNotFoundException: Resource not found at path '/mchange-commons.propertie ...

  9. Spring MVC集成thymeleaf时提示:defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException

    错误提示: defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean ...

随机推荐

  1. 查看Linux系统信息

    1.查看内核 [root@localhost etc]# uname -aLinux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue No ...

  2. Java 继承02

    向上类型转换 父类型的引用指向子类型的实例. Person p = new Person();Animal a = p; //子类对象赋值给父类类型的变量 注意: 向上转型后,子类单独定义的方法会丢失 ...

  3. python 小兵(5)参数

    我们目前为止,已经可以完成一些软件的基本功能了,那么我们来完成这样一个功能:约x 1 2 3 4 5 pint("拿出手机") print("打开陌陌") pr ...

  4. Promise、Generator、Async有什么区别?

    前言 我们知道Promise与Async/await函数都是用来解决JavaScript中的异步问题的,从最开始的回调函数处理异步,到Promise处理异步,到Generator处理异步,再到Asyn ...

  5. Java中的常用的输入输出流

    Java中的输入输出流根据格式又可以分为字节流和字符流:(成对) 字节流:FileInputStream,FileOutputStream   :  BufferedInputStream,Buffe ...

  6. File常用的方法

    import java.io.File; import java.io.IOException; /* 创建: createNewFile() 在指定位置创建一个空文件,成功就返回true,如果已存在 ...

  7. HDOJ acm steps 3.1.1

    (都是递推求值,呵呵,好开心- - ) 今天又是在自习室通宵(文明玩的停不下来了) 游戏玩完想想该水题了,于是打开了HDOJ的ACM STEPS(这是个好东西,就像他的名字,一步步来的) 2.3.x貌 ...

  8. Linux Ubuntu安装Nvidia多GPU通信库NCCL

    0. 前言 在使用Python版本的PaddleDetection进行一些实验时,想同时利用多个GPU提高效率,遇到了一点问题 You may need to install 'nccl2' from ...

  9. linux_4

    自建yum仓库,分别为网络源和本地源 编译安装http2.4 linux命令练习 列出ubuntu软件管理工具apt的一些用法(自由总结)

  10. charles模拟弱网

      Charles操作:延迟设置 >选择相应的网络延迟设置或者自定义延迟 >开启延迟即可,如图: