使用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. nginx二进制安装

    目录 一:二进制安装nginx 1.下载CentOS源 2.安装CentOS源 3.下载epel源(失败显示未找到命令) 4.解决依赖 5.安装Epel源 6.安装nginx 一:二进制安装nginx ...

  2. Java多线程专题6: Queue和List

    合集目录 Java多线程专题6: Queue和List CopyOnWriteArrayList 如何通过写时拷贝实现并发安全的 List? CopyOnWrite(COW), 是计算机程序设计领域中 ...

  3. hashmap 实现 相同的key值时,value值叠加效果。

    一,了解一些基础 package com.ohs.demo; /** * * 一.需求是:停止相同的key值,覆盖效果,将重复的value值,叠加起来. * * 二.hash? 什么是hash? * ...

  4. django之js模板插件artTemplate的使用

    安装: 方式1:artTemplate模板源码下载地址:https://aui.github.io/art-template/zh-cn/index.html 方式2:使用node.js进行安装:np ...

  5. freeswitch对接电信线路VOLTE视频通话

    在public.xml上设置视频编码: <action application="export" data="nolocal:absolute_codec_stri ...

  6. nextcloud个人云搭建

    nextcloud个人云搭建 目录 nextcloud个人云搭建 树莓派安装系统 安装OMV5 安装dockcer 挂载硬盘进行映射(使用u盘测试的) 不足 配置数据库 使用docker拉取postg ...

  7. c#序列化和反序列化《转载》

    (一)使用总体说明 .net framework的类库中提供了三个可以用于序列化和反序列化的类,分别为BinaryFormatter.SoapFormatter和XmlSerializer. Bina ...

  8. 数论同余学习笔记 Part 2

    逆元 准确地说,这里讲的是模意义下的乘法逆元. 定义:如果有同余方程 \(ax\equiv 1\pmod p\),则 \(x\) 称为 \(a\bmod p\) 的逆元,记作 \(a^{-1}\). ...

  9. CF1399F Yet Another Segments Subset

    首先注意一下题面要求,使得选出的线段两两要么包含要么不相交,也就是说一条线段可能会出现不相交的几条线段,而这些线段上面也可能继续这样包含线段.然后我们可以发现我们要做的实际上是在这条线段上选取几条线段 ...

  10. nginx开发:ngx_sprintf

    格式化参数%系列,如果误用的话,轻则输出不正确,重则nginx可能core. 1. 格式: %{格式描述}{输出类型描述}{数据类型描述} 2. 数据类型描述: V:字符串,对应ngx_str_t * ...