When I run the following code
I get this error messageCan someone help me with this issue?
Code:
from PIL import Imagefrom PIL import Imagefrom PIL import ImageDrawfrom PIL import ImageFontimport ST7735import osdisp = ST7735.ST7735(port=0, cs=0, dc=24, backlight=None, rst=25, width=128, height=160, rotation=0, invert=False)WIDTH = disp.widthHEIGHT = disp.heightimg = 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 textdraw.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)
Code:
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
Statistics: Posted by Kenne76 — Sun May 05, 2024 5:52 pm