成功解决OSError: cannot open resource File F:Python36\lib\site-packages\PIL\ImageFont.py, self.font
成功解決OSError: cannot open resource File "F:Python36\lib\site-packages\PIL\ImageFont.py", self.font
?
?
目錄
解決問題
解決思路
解決方法
?
?
?
解決問題
? File "F:Python36\lib\site-packages\PIL\ImageFont.py", line 144, in __init__
? ? self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine)
OSError: cannot open resource
?
解決思路
?self.font = core.getfont(font, size, index, encoding, layout_engine=layout_engine)
OSError:無法打開資源,
兩個原因
T1、加載的字體文件路徑不對!,很有可能是加載的文件名字過長,文件名過長也不行的!
T2、加載的字體文件有問題!
?
解決方法
1、先參考StackOverflow網(wǎng)友的解答:https://stackoverflow.com/questions/47694421/pil-issue-oserror-cannot-open-resource
I have also met this issue on Windows 10 Pro with PIL 5.3.0.
On my machine, the error is caused by non-ASCII font file names. If I change the the font name to only contain ASCII characters, I can open the font without any error.
?
2、博主自己的解決辦法
博主是因為加載字體的文件路徑不對造成的!把字體放在同代碼文件夾下邊即可!博主更改加載路徑的方法也成功!
大功告成!
?
?
?
?
?
?
?
總結
以上是生活随笔為你收集整理的成功解决OSError: cannot open resource File F:Python36\lib\site-packages\PIL\ImageFont.py, self.font的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 成功解决cv2.error: C:\pr
- 下一篇: 成功解决OSError: cannot