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:
- Mac Upgrade pip Error OSError: [Errno 13] Permission denied: ‘/Library/Python/2.7/site-packages/pip-9.0.1-py2….
- [Solved] Python Pandas Read Error: OSError: initializing from file failed
- [Solved] Python Read bam File Error: &&OSError: no BGZF EOF marker; file may be truncated
- [Solved] Python project runs the open() function error: FileNotFoundError: [Errno 2] No such file or directory
- OSError libespeak.so.1 error: no such file or directory [How to Solve]
- OSError: [WinError 1455] The page file is too small to complete the operation. Error loading…
- Brew Install python Error: tar: Error opening archive: Failed to open’***‘
- Invalid python sd, Fatal Python error: init_fs_encoding: failed to get the Python cod [How to Solve]
- Python openpyxl excel open zipfile error resolution: zipfile.BadZipFile: File is not a zip file
- [Solved] NPM install Error: check python checking for Python executable python2 in the PATH
- How to Solve Python WARNING: Ignoring invalid distribution -ip (e:\python\python_dowmload\lib\site-packages)
- Error:Could not install packages due to an OSError:[WinError 5] Access denied
- [Solved] opencv-python: recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all‘ failed
- [Solved] RuntimeError: cublas runtime error : resource allocation failed at
- [Solved] Error starting proxy server: oserror (10013), “an attempt was made to access the socket in a way that the access permission is not allowed.”, None, 10013, None)
- [Solved] pycuda._driver.LogicError: cuFuncSetBlockShape failed: invalid resource handle
- [Solved] socketio.exceptions.ConnectionError: OPEN packet not returned by server
- [Solved] Python matplotlib Error: RuntimeError: In set_size: Could not set the fontsize…
- Python Error: pip install mysql-connector-python failed
- Linux installs Python and upgrades Python