Pillow模块ImageFont字体路径报错问题

环境:

Python3.6.8

Django2.2.17

Apache24

Windows10

 

Django项目中用到了Pillow模块,ImageFont.truetype()可以用来设置字体路径,改路径要设置成绝对路径,在Django中我是这样配置的:

ImageFont.truetype(os.path.join(settings.STATICFILES_DIRS[0], 'font', '***.ttf'), 26)

如果设置的是相对路径,PyCharm调试没问题,部署到Apache24会报错。

posted @ 2021-02-05 16:09  etdreamer  阅读(774)  评论(0)    收藏  举报