osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

IOError: cannot open resource


RobH wrote:

> When I run a python project with an oled display on a rasperry pi zero,
> it calls for the Minecraftia.ttf font. I have the said file in
> home/pi/.fonts/
> 
> I get this error:
> 
> pi at raspberrypi:~/Downloads $ python interdisplay.py
> Traceback (most recent call last):
>    File "interdisplay.py", line 220, in <module>
>      display_time()
>    File "interdisplay.py", line 26, in display_time
>      font = ImageFont.truetype('home/pi/.fonts/Minecraftia.ttf', 35)
>    File "/usr/lib/python2.7/dist-packages/PIL/ImageFont.py", line 280,
> in truetype
>      return FreeTypeFont(font, size, index, encoding, layout_engine)
>    File "/usr/lib/python2.7/dist-packages/PIL/ImageFont.py", line 145,
> in __init__
>      layout_engine=layout_engine)
> IOError: cannot open resource
> 
> PILLOW version forked from PIL 1.1.7
> 
> I have no idea to what to do about this.

You don't have the font "Minecraftia.ttf". You can either try to find and 
install it or replace it with another that you already have in the 
/home/pi/.fonts directory.

You may even lie about it, e. g. assuming there is a font called 
"NotoSerif-Regular.ttf"

$ cd /home/pi/.fonts
$ ln NotoSerif-Regular.ttf Minecraftia.ttf

should fix the error without making changes to the code.