日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

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

發(fā)布時間:2025/3/21 python 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 成功解决OSError: cannot open resource File F:Python36\lib\site-packages\PIL\ImageFont.py, self.font 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

成功解決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)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。