FlexSim unable to bind external Python function (Code Binding Error)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone,
I’m trying to use FlexSim’s feature to call external Python code from within a FlexSim model (FlexSim version 25.2). Specifically, I want to call a Python module named PyMod which contains a function PyFunc.
I tried two different approaches, both using Process Flow:
Attempt 1 — Custom Code block (externally linked code)
In Process Flow I used a Custom Code activity and enabled Make Code Externally Linked. Inside that block I added the following binding:
/**external python: */ /**/"PyMod"/**/
/** \nfunction name:*/ /**/"PyFunc"/**/
Attempt 2 — User Command + Assign Label
I created a User Command called CallPython with the same external Python binding:
Then, in Process Flow, I used an Assign Label activity that creates a label named test with value CallPython().
(I leave the parentheses empty because the Python function does not require arguments.)
This Assign Label is also connected to a Source so a token reaches it.
At the moment my Python file is just a test and should return a simple string:
# PyMod.py
def PyFunc():
return "OK from Python"
I checked the Python version installed on my PC and the one selected in FlexSim, and they match (Python 3.12).
In both attempts, when I press Run, FlexSim shows a message:
FlexSim was unable to load the connector for the python language.
And in the console I get:
How can I fix this so FlexSim can successfully create the Python connection and run the external Python file?
Thanks in advance!