Python

LaTeX templates with Python and Jinja2 to generate PDFs

The Jinja templating engine works well to create LaTeX templates for generating PDF files. The only issue is the default Jinja block, variable, and comment identification strings can conflict with the LaTeX commands. A solution is to change the Jinja environment to mimic the LaTeX environment.

Here is an example. This is the python file test.py:

Python paths in subprocess.popen with Apache mod_wsgi and virtualenv

If you are using subprocess.Popen to run an external process while running Python/Django with a virtual environment in Apache via mod_wsgi you'll discover the new processes run outside of your virtual environment. In my case, I need to set the PYTHONPATH environment variable to get everything straight. Rather than hardcode it or the sys.path in the external script, I'd like to set it to the same value as the existing environment.

Subscribe to Python