csgoh / processpiper

An open source python library to generate business process diagram using code or plain text.
https://github.com/csgoh/processpiper
MIT License
148 stars 10 forks source link

OSError: cannot open resource for README example #7

Closed galenseilis closed 1 year ago

galenseilis commented 1 year ago

After running pip install processpiper I tried this string example from the README:

from processpiper.text2diagram import render

input_syntax = """
title: Sample Test Process
colourtheme: BLUEMOUNTAIN
    lane: End User
        (start) as start
        [Enter Keyword] as enter_keyword
        (end) as end
pool: System Search
    lane: Database System
        [Login] as login
        [Search Records] as search_records
        <Result Found?> as result_found
        [Display Result] as display_result
        [Logout] as logout
    lane: Log System
        [Log Error] as log_error

start->login->enter_keyword->search_records->result_found->display_result->logout->end
result_found->log_error->display_result

footer: Generated by ProcessPiper
"""

render(input_syntax, "my_process_map.png")

Here is the traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/text2diagram.py", line 259, in render
    exec(generated_code)
  File "<string>", line 26, in <module>
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/processmap.py", line 451, in draw
    self.set_draw_position(self.__painter)
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/processmap.py", line 320, in set_draw_position
    self._title.set_draw_position(
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/title.py", line 46, in set_draw_position
    self.width, self.height = painter.get_text_dimension(
  File "/home/galen/.local/lib/python3.10/site-packages/processpiper/painter.py", line 945, in get_text_dimension
    image_font = ImageFont.truetype(self.get_font_path(font), font_size)
  File "/home/galen/.local/lib/python3.10/site-packages/PIL/ImageFont.py", line 996, in truetype
    return freetype(font)
  File "/home/galen/.local/lib/python3.10/site-packages/PIL/ImageFont.py", line 993, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/home/galen/.local/lib/python3.10/site-packages/PIL/ImageFont.py", line 248, in __init__
    self.font = core.getfont(
OSError: cannot open resource

My version of pillow is 9.5.0.

Here is my OS info: Linux Ganymede 5.15.0-71-generic #78-Ubuntu SMP Tue Apr 18 09:00:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

I am running Python 3.10.6.

csgoh commented 1 year ago

Hi, please see this page (https://github.com/csgoh/processpiper/wiki/installation) for additional steps to install mscorefonts on Linux. This is a known dependency for now, and the aim is to remove the reliance on the 'Arial' font for the Linux platform in the next release.

galenseilis commented 1 year ago

That did the trick.