日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

成功解决OSError: cannot open resource File F:Python36\lib\site-packages\PIL\ImageFont.py, self.font

發布時間:2025/3/21 53 豆豆
生活随笔 收集整理的這篇文章主要介紹了 成功解决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網友的解答: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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。