Skip to main content
Question

Challenges with Python in FME 2024.


tb09114
Supporter
Forum|alt.badge.img+23

 I have an issue with some Python code in Form 2024.1.

I have to make a connection to a PostgreSQL database using psycogp2. When I run the PythonCaller in my workspace then it fails with an error message that psycogp2 is missing (Python Exception <ModuleNotFoundError>: No module named 'psycopg2')

I tried to single out the problem in a minimal workspace (attached), but here it works without a problem. Hence, I am wondering how and what is causing the issue. The actual workspace is rather big and I will share a screenshot of the essential part that is failing.

The AttributeManager10 receives a single feature from the summary port of a FeatureWriter and in AttributeManager10 all other exposed attributes are deleted, except the site_id (integer) is kept. Unexposed attributes are there only two:

  1. fme_geometry -> fme_undefined
  2. fme_type -> fme_no_geom

 

Running to the Attributemanager10 works fine. The next partial run of PythonCaller_4 fails with:

2025-04-30 13:46:19| 3.6| 3.4|ERROR |Message Type: fme::internal::_v0::py::Exception
2025-04-30 13:46:19| 3.6| 0.0|ERROR |Python Exception <ModuleNotFoundError>: No module named 'psycopg2'
2025-04-30 13:46:19| 3.6| 0.0|ERROR |Error encountered while calling method `input'
2025-04-30 13:46:19| 3.6| 0.0|FATAL |PythonCaller_4 (PythonFactory): PythonFactory failed to process feature

 

Don’t get me wrong, we are talking about the same FME Form, where the PythonCaller works in one workspace with and integer as input and where it does not in the other workspace, claiming a Python module it can find earlier is not to be found 5 seconds later.

2 replies

david_r
Celebrity
  • May 1, 2025

How/where did you install the Python libraries? Did you install psycopg2 etc. in the high-level Python plugin folder, or inside a version-specific folder?

Have both workspaces been configured to use the exact same Python interpreter?


david_r
Celebrity
  • May 1, 2025

Disregarding the PythonCaller, you could accomplish the same thing as your sample Python code using a regular SQLExecutor and the following query:

select dist_to_coast 
from public.site_distance_coast 
where site_id = @Value(site_id)
limit 1

 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings