Calling python functions that requires ortools fails

Calling python functions that requires ortools fails

pcneo
Advocate Advocate
62 Views
0 Replies
Message 1 of 1

Calling python functions that requires ortools fails

pcneo
Advocate
Advocate

I have set up a Flexsim model calling 3 python functions, with their return values written into labels in a token:

a) function that uses numpy (data)

    This works fine. (It first failed until I install numpy onto this python version)

b) function that checks existence of ortools (data1)

    This locates the ortools using importlib.util.find_spec("ortools") successfully

c) function that import ortools (data2)

    This fails at the statement: from ortools.sat.python import cp_model

 

As evidence that the 3 functions run fine or fail, the values for the 3 labels are shown. 

pcneo_1-1787829729747.png

 

Flexsim is started on a command prompt with PATH pointing only to 1 version of python (3.12.7).

Note: If the statement import ortools.sat.python import cp_model is moved up to the top few lines, none of the functions will run successfully.

 

Note: All 3 python functions run well in a standalone python environment.

 

The model and python file is attached. Please rename pymod1.txt to pymod1.py.

 

Any idea what causes the issue?

 

0 Likes
63 Views
0 Replies
Replies (0)