Skip to main content

Hello FME Community,

I’m encountering a puzzling issue with a Jinja2 template that I’m running through the PythonCaller in FME Flow. The template works perfectly fine on my local machine, but when I deploy the same script on FME Flow, I receive the following error:

Python Exception <TemplateSyntaxError>: expected token 'end of print statement', got 'X'

Context:

The Jinja2 template is used to generate a Contract document with placeholders that are populated at runtime. Below is a simplified version of the template:

Contract
1. A Person with these Details

2. Name: {{ tag1 }}
   Postcode: {{ tag2 }}
   Date of Birth: {{ tag3 }}
   E-mailadres: {{ tag4 }}

{% for compensation in compensation%}
located at the* / the*: {{ fee.tag70 }}    
section: {{ fee.tag4 }}    
number(s): {{ fee.tag5 }}
{% endfor %}

Steps Taken:

  • Local Testing: The template renders correctly when I run it locally using Python (same Jinja2 template) on my machine.
  • FME Flow Execution: When running the same script on FME Flow, it fails with the TemplateSyntaxError mentioned above.
  • Data Consistency: I confirmed that all necessary data tags are populated and passed correctly to the template.

Request for Help:

I'm reaching out to see if anyone in the community has encountered a similar issue or might have insights into what could be going wrong. Specifically:

  • Has anyone experienced differences in how Jinja2 templates are processed between local Python environments and FME Flow?
  • Are there known issues or configuration settings in FME Flow that might cause this behavior?
  • Any tips on how to further debug this issue within the FME Flow environment?

Thanks in advance for your help.

Hi @ahmadrezakarim ,

     When using Python modules which are not included in the base installation of FME Flow, you will need to manually add these modules to your Resources page in the Web UI, under Engines\plugins\python. There are step by step instructions on how to do this provided here. After uploading the module, restart your FME Flow instance and try running the job with the PythonCaller again.

-- Luke H


Hi @ahmadrezakarim ,

     When using Python modules which are not included in the base installation of FME Flow, you will need to manually add these modules to your Resources page in the Web UI, under Engines\plugins\python. There are step by step instructions on how to do this provided here. After uploading the module, restart your FME Flow instance and try running the job with the PythonCaller again.

-- Luke H

Thank you, Luke, for your answer. I have already installed Jinja2 and followed the steps you mentioned. I have run the PythonCaller in different scenarios (different types of contracts), but with this one, I encounter the aforementioned error.


Reply