v22.1 "Code Binding Error: could not bind to function"

v22.1 "Code Binding Error: could not bind to function"

guillem_f
Not applicable
20 Views
4 Replies
Message 1 of 5

v22.1 "Code Binding Error: could not bind to function"

guillem_f
Not applicable

[ FlexSim 22.1.0 ]

I'm trying to test the new python external code functionality (release 22.1) through alan.zhang's example on 'Future Python and FlexSim integration':

pymod.py

python-test.fsm

The following error pops:

exception: Code Binding Error: could not bind to function
Node: /Tools/UserCommands/python_test/code
Binding string: external python "pymod" "PyFunc"
Windows Error Code : 126

A similar error was discussed in 'Cannot bind to Python function', but quite not the same, as I'm saving both the flexsim and the python docs in the same folder.

I'm not sure if the python environment matters (currently using Spyder), but at this point I could blame it on anything, since I tried many things but the error persists.

I appreciate any attention, thanks in advance.

0 Likes
Accepted solutions (1)
21 Views
4 Replies
Replies (4)
Message 2 of 5

guillem_f
Not applicable
0 Likes
Message 3 of 5

philboboADSK
Autodesk
Autodesk
Accepted solution

The model and python script are fine.

Make sure you have installed and configured python correctly on your system.

Python's location should be in your PATH environment variable, and the correct version number of that Python install should be specified in the Code tab of your Global Preferences in FlexSim:

1650471072768.png




Phil BoBo
Sr. Manager, Software Development
Message 4 of 5

guillem_f
Not applicable

I've added python to my User and System PATH environment variables (Not sure if I should change both). Now my flexsim model crashes when it connects to external code. The name of the archive makes no difference: the model would just crash with any given archive name on the 'external code' code.

When checking if python is on my PATH with cmd, it shows the following:

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

Which I could solve temporarily by executing in cmd:

C:\Users\Flexsim\anaconda3\Scripts\activate base

But still get the same crashing problem on flexsim.

(I also tried reinstalling python and anaconda, and tried many other that led to no improvement)

0 Likes
Message 5 of 5

guillem_f
Not applicable

It worked, by uninstalling anaconda and reinstalling python from python.org.

0 Likes