Question:
File "D:\Windows_DL_Environment\anaconda3\envs\py37\lib\site-packages\PIL\ImageFont.py", line 852, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "D:\Windows_DL_Environment\anaconda3\envs\py37\lib\site-packages\PIL\ImageFont.py", line 212, in __init__
font, size, index, encoding, layout_engine=layout_engine
OSError: cannot open resource
This class is a common font problem. In Windows environment, fonts are generally located in the C:\windows\fonts folder. In this folder, users can check whether the font specified in the python program exists.
fnt = ImageFont.truetype('Pillow/Tests/fonts/FreeMono.ttf', 50)
Solution 1:
Change the font that exists on the computer
ImageFont.truetype("Pillow/Tests/fonts/arial.ttf", 50)
Solution 2:
Found no freemono in the computer Ttf font, so you need to download
https://fontmeme.com/ziti/freemono-font/
After downloading, unzip it into the fonts folder
finally. Restart the computer to execute.
Read More:
- [Solved] Python matplotlib Error: RuntimeError: In set_size: Could not set the fontsize…
- [Solved] ParserError: NULL byte detected. This byte cannot be processed in Python‘s native csv library
- Python automatically generates the requirements file for the current project
- Python Use sqlalchemy Error: pymssql.ProgrammingError: (102, b“Incorrect syntax near ‘(‘.DB-Lib error
- Error reading file by pandas pandas.errors.EmptyDataError: no columns to parse from file
- OSError libespeak.so.1 error: no such file or directory [How to Solve]
- [Solved] matplotlib.units.ConversionError: Failed to convert value(s) to axis units: ‘LiR‘
- pandas.DataFrame() Initializes NULL Error: DataFrame [How to Solve]
- [Solved] RuntimeError: cublas runtime error : resource allocation failed at
- Pytorch ValueError: Expected more than 1 value per channel when training, got input size [1, 768
- How to Solve Error: RuntimeError CUDA out of memory
- numpy.concatenate() 253rd; 38169Keyerror: 0 [How to Solve]
- [Solved] ValueError: check_hostname requires server_hostname
- [Solved] Selenium.common.exceptions.WebDriverException: Message: newSession
- How to Solve Python Xlwt ValueError: More than 4094 XFs (styles)
- An error is reported in the requirements code of the generated project
- AttributeError: can‘t set attribute [How to Solve]
- Gunicorn Flask Error: [ERROR] Socket error processing request
- visdom Install and Run Error: raise Connectionerror [How to Solve]
- [Solved] Grid Search Error (GridSearchCV): ‘ascii‘ codec can‘t encode characters in position 18-20: ordinal not in r