Python failed to use PIL writer library. TTF, etc. oserror: cannot open resource

Error information

Read the error information,
return freetype (font),
return freetype font (font, size, index, encoding, layout)_ Oserror: cannot open resource
generally, an error is reported. The reason is that there is a problem in using the resource file
failure reason:
1. First of all, check whether the path you bind is correct. Some people directly bind to the font file in the path of C: (Windows) fonts. This is OK, but you need to use it in Python/
2. If you bind to the font file in the path of C: (Windows) fonts, you can’t use it. Reason: the name of the font may be too long. At this time, we can rename it, Then re install to the path, or directly put your own bound path
3. The bound path is correct, but still an error is reported. Trust the font library to C:// Windows/fonts to see if it is installed. If it is not installed, it may not work

File "./ClothStore/captcha/captcha.py", line 123, in <listcomp>
    for size in font_sizes or (65, 70, 75)])
  File "/home/ClothStore/venv/lib/python3.7/site-packages/PIL/ImageFont.py", line 655, in truetype
    return freetype(font)
  File "/home/ClothStore/venv/lib/python3.7/site-packages/PIL/ImageFont.py", line 652, in freetype
    return FreeTypeFont(font, size, index, encoding, layout_engine)
  File "/home/ClothStore/venv/lib/python3.7/site-packages/PIL/ImageFont.py", line 194, in __init__
    font, size, index, encoding, layout_engine=layout_engine
OSError: cannot open resource

Read More: