![](/img/trans.png)
[英]reportlab.pdfbase.ttfonts.TTFError: Can't open file “Times New Roman.ttf”
[英]python Django reportlab can't find msyh.ttf file
當我使用
from reportlab.pdfbase import pdfmetrics
pdfmetrics.registerFont(TTFont('msyh', 'msyh.ttf'))
我遇到了一個錯誤
reportlab.pdfbase.ttfonts.TTFError: Can't open file "msyh.ttf"
但是,如果我下載 msyh.ttf 文件並使用絕對路徑,例如
pdfmetrics.registerFont(TTFont('msyh', r'C:\Users\xxx\xxx\xxx\xxx\msyh.ttf'))
有用。
我怎樣才能修復這個錯誤?
我通過在我的 venv 目錄中安裝 msyh.ttf 來解決我的問題......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.