我正在使用python生成令牌作为安全措施。这是代码:
ERROR in app: Exception on /registration [POST], referer: http://my.com/registration
Traceback (most recent call last):, referer: http://my.com/registration
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1982, in wsgi_app, referer: http://my.com.com/registration
response = self.full_dispatch_request(), referer: http://my.com/registration
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1614, in full_dispatch_request, referer: http://my.com/registration
rv = self.handle_user_exception(e), referer: http://my.com/registration
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1517, in handle_user_exception, referer: http://my.com/registration
reraise(exc_type, exc_value, tb), referer: http://my.com/registration
File "/usr/local/lib/python3.5/dist-packages/flask/_compat.py", line 33, in reraise, referer: http://my.com/registration
raise value, referer: http://my.com/registration
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1612, in full_dispatch_request, referer: http://my.com/registration
rv = self.dispatch_request(), referer: http://my.com/registration
File "/usr/local/lib/python3.5/dist-packages/flask/app.py", line 1598, in dispatch_request, referer: http://my.com/registration
return self.view_functions[rule.endpoint](**req.view_args), referer: http://my.com/registration
File "/var/www/rci/rciApp/__init__.py", line 260, in registration, referer: http://my.com/registration
font = ImageFont.truetype("arial.ttf", 15), referer: http://my/registration
File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 239, in truetype, referer: http://my.com/registration
return FreeTypeFont(font, size, index, encoding), referer: http://my.com/registration
File "/usr/lib/python3/dist-packages/PIL/ImageFont.py", line 128, in __init__, referer: http://my.com/registration
self.font = core.getfont(font, size, index, encoding), referer: http://my.com/registration
OSError: cannot open resource, referer: http://my.com/registration
错误似乎是加载字体的能力。虽然我从PIL导入ImageFont。
错误信息如下:
d3.select('#date_select').on('change', function(){
var nd = new Date(), now = new Date();
switch (this.value) {
case "today":
nd = d3.time.day(now);
break;
case "week":
nd = d3.time.monday(now);
break;
case "month":
nd = d3.time.month(now);
break;
default:
nd.setDate(nd.getDate() - +this.value);
}
dim.filterAll();
dim.filterRange([nd, now]);
//did not work graph.replaceFilter(dc.RangedFilter(nd, now));
graph.redrawGroup();
});
我的理解是ImageFont导致问题,因为它无法加载正确的字体。我不知道如何解决它。更令人费解的是它曾经工作过,直到我把它放在服务器上。
答案 0 :(得分:1)
遇到相同的问题,很明显font
无法找到PIL
文件。
在font = ImageFont.truetype("arial.ttf", 15)
中找不到arial.ttf
。
解决方案是CD /usr/share/fonts/truetype
,并找到可用的字体文件,然后用"arial.ttf"
替换。(对于Windows用户,C:\WINDOWS\Fonts
中的字体文件)< / p>