When I run the following code
from PIL import Image
from PIL import Image
from PIL import ImageDraw
from PIL import ImageFont
import ST7735
import os
disp = ST7735.ST7735(port=0, cs=0, dc=24, backlight=None, rst=25, width=128, height=160, rotation=0, invert=False)
WIDTH = disp.width
HEIGHT = disp.height
img = Image.new('RGB', (WIDTH, HEIGHT))
draw = ImageDraw.Draw(img)
font_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'fonts', 'PixelOperator.ttf'))
font2 = ImageFont.truetype(font_path, 16)
# Write some text
draw.text((0,0), "Uptime: ", font=font2, fill="red")
draw.text((0,15), "Hostname: ", font=font2, fill="red")
draw.text((67,15), "Q3Server", font=font2, fill="white")
draw.text((0,30), "IP: ", font=font2, fill="red")
draw.text((0,45), "CPU Usage: ", font=font2, fill="red")
draw.text((0,60), "CPU Temp: ", font=font2, fill="red")
draw.text((0,75), "Ram: ", font=font2, fill="red")
draw.text((0,90), "SD Card: ", font=font2, fill="red")
#draw.text((0, 105), "Network: ", font=font2, fill="red")
# Write buffer to display hardware, must be called to make things visible on the
# display!
disp.display(img)
I get this error message
Traceback (most recent call last):
File "/home/ken/Programming/weather/test4.py", line 17, in <module>
font2 = ImageFont.truetype(font_path, 16)
File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 861, in truetype
return freetype(font)
File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 858, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 203, in __init__
self.font = core.getfont(
OSError: cannot open resource
Can someone help me with this issue?