am new to python and i am trying to get flask micro-framework to work with apache. I am using the wsgi setup instructions as described in the following article: https://www.digitalocean.com/community/articles/how-to-deploy-a-flask-application-on-an-ubuntu-vps
unfortunately, although the application works fine, when trying to produce a pdf using reportlab I am getting the following error (extract from apache logs)
[Thu Jan 09 22:47:44 2014] [error] ERROR:flaskapp:Exception on /print/0 [GET]
[Thu Jan 09 22:47:44 2014] [error] Traceback (most recent call last):
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
[Thu Jan 09 22:47:44 2014] [error] response = self.full_dispatch_request()
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
[Thu Jan 09 22:47:44 2014] [error] rv = self.handle_user_exception(e)
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
[Thu Jan 09 22:47:44 2014] [error] reraise(exc_type, exc_value, tb)
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
[Thu Jan 09 22:47:44 2014] [error] rv = self.dispatch_request()
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
[Thu Jan 09 22:47:44 2014] [error] return self.view_functions[rule.endpoint](**req.view_args)
[Thu Jan 09 22:47:44 2014] [error] File "/var/www/flaskapp/flaskapp/__init__.py", line 124, in print_rep
[Thu Jan 09 22:47:44 2014] [error] registerFont(TTFont('DroidSans', 'DroidSans.ttf'))
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfbase/ttfonts.py", line 1009, in __init__
[Thu Jan 09 22:47:44 2014] [error] self.face = TTFontFace(filename, validate=validate, subfontIndex=subfontIndex)
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfbase/ttfonts.py", line 915, in __init__
[Thu Jan 09 22:47:44 2014] [error] TTFontFile.__init__(self, filename, validate=validate, subfontIndex=subfontIndex)
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfbase/ttfonts.py", line 412, in __init__
[Thu Jan 09 22:47:44 2014] [error] TTFontParser.__init__(self, file, validate=validate,subfontIndex=subfontIndex)
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfbase/ttfonts.py", line 189, in __init__
[Thu Jan 09 22:47:44 2014] [error] self.readFile(file)
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfbase/ttfonts.py", line 263, in readFile
[Thu Jan 09 22:47:44 2014] [error] self.filename, f = TTFOpenFile(f)
[Thu Jan 09 22:47:44 2014] [error] File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfbase/ttfonts.py", line 175, in TTFOpenFile
[Thu Jan 09 22:47:44 2014] [error] raise TTFError('Can\\'t open file "%s"' % fn)
[Thu Jan 09 22:47:44 2014] [error] TTFError: Can't open file "DroidSans.ttf"
it looks like that the registerFont can't access the font.
running it in the development server, it works fine.
I tried several locations, even putting the font in a font folder within the reportlab folder but still nothing. looked in this article that suggests fast_cgi (for Django) but I am not sure if this will solve my problem.
python reportlab - registerFont - django - font not available after some time
any ideas? Thanks
font files must be in paths declared in reportlab.rl_config.TTFSearchpath (search path list)
Try to output list content.
And, no, switching to fast_cgi with Django won't make you understand what went wrong.