zoukankan      html  css  js  c++  java
  • IOError: cannot open resource

    在运行PIL_test.py文件的时候报错:

    File "PIL_test.py", line 40, in <module>
    font = ImageFont.truetype('/usr/share/fonts/Arial.ttf', 36)
    File "/usr/lib64/python2.6/site-packages/PIL/ImageFont.py", line 205, in truetype
    return FreeTypeFont(filename, size, index, encoding)
    File "/usr/lib64/python2.6/site-packages/PIL/ImageFont.py", line 121, in __init__
    self.font = _imagingft.getfont(file, size, index, encoding)
    IOError: cannot open resource

    原因是找不到字体的资源文件

    解决办法:

    从window下找到字体的资源文件,并拷贝到/usr/share/fonts/目录下。

    然后定义font对象的时候写上字体的存放的完整路径

    font = ImageFont.truetype('/usr/share/fonts/arial.ttf', 36)。运行通过。

  • 相关阅读:
    Linux Netcat命令
    clang-format
    keytool
    ip
    Linux iptables
    Linux yum源完全配置
    Makefile
    CMake
    HSTS
    开源镜像
  • 原文地址:https://www.cnblogs.com/lisuyun/p/7077375.html
Copyright © 2011-2022 走看看