Re: IOError: cannot open resource
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@raspberrypi:~/Downloads $ python interdisplay.py Traceback (most recent call last): File "interdisplay.py", line 220, in 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. -- https://mail.python.org/mailman/listinfo/python-list
Re: IOError: cannot open resource
On 07/12/2019 16:58, Michael Torrie wrote: On 12/7/19 9:48 AM, RobH wrote: On 07/12/2019 16:00, Dan Sommers wrote: On 12/7/19 9:43 AM, 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/ Do you mean /home/pi/.fonts (with a leading slash, an absolute path rather than a relative one)? Dan Not sure how you mean, but it is just as I typed it, with a forward or leading slash. I have it solved now, with a different font. What he means is that according to the stack trace you were asking for: home/pi/.fonts/Minecraftia.ttf instead of /home/pi/.fonts/Minecraftia.ttf If you cut and paste the traceback then that is what happened. Likely when you tried a different font you added the missing / and all was well. Yes that is correct, my mistake. -- https://mail.python.org/mailman/listinfo/python-list
Re: IOError: cannot open resource
On 12/7/19 9:48 AM, RobH wrote: > On 07/12/2019 16:00, Dan Sommers wrote: >> On 12/7/19 9:43 AM, 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/ >> >> Do you mean /home/pi/.fonts (with a leading slash, an absolute path >> rather than a relative one)? >> >> Dan > > Not sure how you mean, but it is just as I typed it, with a forward or > leading slash. > I have it solved now, with a different font. What he means is that according to the stack trace you were asking for: home/pi/.fonts/Minecraftia.ttf instead of /home/pi/.fonts/Minecraftia.ttf If you cut and paste the traceback then that is what happened. Likely when you tried a different font you added the missing / and all was well. -- https://mail.python.org/mailman/listinfo/python-list
Re: IOError: cannot open resource
On 07/12/2019 16:00, Dan Sommers wrote: On 12/7/19 9:43 AM, 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/ Do you mean /home/pi/.fonts (with a leading slash, an absolute path rather than a relative one)? Dan Not sure how you mean, but it is just as I typed it, with a forward or leading slash. I have it solved now, with a different font. -- https://mail.python.org/mailman/listinfo/python-list
Re: IOError: cannot open resource
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@raspberrypi:~/Downloads $ python interdisplay.py Traceback (most recent call last): File "interdisplay.py", line 220, in 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. -- https://mail.python.org/mailman/listinfo/python-list
Re: IOError: cannot open resource
On 12/7/19 9:43 AM, 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/ Do you mean /home/pi/.fonts (with a leading slash, an absolute path rather than a relative one)? Dan -- https://mail.python.org/mailman/listinfo/python-list
Re: 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@raspberrypi:~/Downloads $ python interdisplay.py > Traceback (most recent call last): >File "interdisplay.py", line 220, in > 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. -- https://mail.python.org/mailman/listinfo/python-list