IOError: cannot open resource

Python python at python.invalid
Sat Dec 7 18:08:08 EST 2019


RobH wrote:
> On 07/12/2019 16:04, Peter Otten wrote:
>> 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.
>>
> 
> Thanks for that.
> I actually replaced Minecraftia.ttf in the code for 
> NotoSerif-Regular.ttf, after I put that font in the .font folder.
> It now runs without the above errors.

You are a genious.





More information about the Python-list mailing list