'Can't add custom font to python with fpdf on linux

I developed a software on my windows machine with fpdf2 for python. It worked perfectly, but now I have to install this program on a Red Hat Linux server and when I try to add custom font to pdf it throws an error: cannot instantiate 'WindowsPath' on your system

the code:

pdf = FPDF()
FONT_REGULAR = os.path.join(os.path.dirname(__file__), "fonts", "arial.ttf")
pdf.add_font("Regular", "", FONT_REGULAR, uni=True)

At this line it throws an error:

<NotImplementedError> "cannot instantiate 'WindowsPath' on your system"

Is there a workaround to this?

fpdf2 version: 2.4.5



Solution 1:[1]

Upgraded to the latest version 2.5.1 and it works with linux also.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1