Hello,
I encountered a crash when saving projects in MFiX 25.3 running on Python 3.13/3.14. The error is:
AttributeError: module 'ast' has no attribute 'Num'
This is because ast.Num and ast.Str have been removed in recent Python versions. I managed to fix this by making the SimpleEval class backwards compatible in the following file:
mfixgui/tools/simpleeval.py
The fix:
I replaced the static dictionary definitions for ast.Num and ast.Str with a conditional check using hasattr. Around line 291 in mfixgui/tools/simpleeval.py, I changed the code to:
python
self.nodes = {
ast.Expr: self._eval_expr,
ast.Assign: self._eval_assign,
ast.AugAssign: self._eval_aug_assign,
ast.Import: self._eval_import,
# Use conditional unpacking for removed AST attributes
**({ast.Num: self._eval_num} if hasattr(ast, 'Num') else {}),
**({ast.Str: self._eval_str} if hasattr(ast, 'Str') else {}),
ast.Name: self._eval_name,
# ... rest of the dict
}
Since the file already handles ast.Constant further down (around line 320), this change allows the GUI to save projects without crashing on newer Python environments while remaining compatible with older versions.
I also noticed ast.Index and ast.Slice are still present in the dictionary. While they didn’t cause a crash in my specific case, they have also been deprecated/removed in newer Python versions and might need similar hasattr checks for full compatibility.
Best regards.