Using python 3.8 for python4Capella

Hi, all. I’m trying to create a scripts to automatize some processes and I would like to call my script from the console or create a new button on the toolbar.
At the moment I’m trying to call the script from the console.
# name : Model Factory
# script-type : Python
# description : MAIN SCRIPT - THE ONLY ONE YOU SHOULD RUN
# toolbar : Console
#
Rest of the script…

This script part worked with python 3.7, with python 3.8 it doesn’t work.
I cannot go back to python 3.7 beacuse it is not compatible with capellambse lib.
Could you help me? :slight_smile:

Hi,

Older versions of Python4Capella would not work with Python versions above 3.7.x, but the last version works with versions of Python below 3.12 (see this issue for more details).

So my guess is updating Python4Capella to 1.2.0 should solve your issue, unless you have some specific code in the script that is not compatible.

To contribute to your script to the user interface you can have a look at this documentation.

If you have an error message maybe I have more ideas about your problem ?

regards.

Hi Siculo/Yvan,

I’ve had the same problem then I have installed Python4Capella 1.2.0 and the code works if i run it as Python run. Now since I want to run it as an EASE script the code does not work anymore: it stalls in “busy” mode without any output.
I have installed the EASE python support 0.8.0. Do you know if this version is compatible with Python 3.8?
Thank you,
regards.

Hi,

You should be able to use Python up to version 3.11. There is a known incompatibility with Python 3.12.

But there is a freeze that happens when numpy is installed in the Python environment, the following issue describe how to path the code from EASE to solve this issue. Can you try this patch an let me known if it helps ?

Hi,

I have tried to use that patch and still, now it gives me this error:

org.eclipse.ease.ScriptExecutionException: Traceback (most recent call last):

  File "workspace://Python4Capella/sample_scripts/XXX/main.py", line 8, in <module>

    # Contributors:

  File "C:\Users\XXX\AppData\Local\Programs\Python\Python38\lib\site-packages\PySimpleGUI\__init__.py", line 2, in <module>

    from .PySimpleGUI import *

  File "C:\Users\XXX\AppData\Local\Programs\Python\Python38\lib\site-packages\PySimpleGUI\PySimpleGUI.py", line 127, in <module>

    tclversion_detailed = tkinter.Tcl().eval('info patchlevel')

  File "C:\Users\XXX\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 2363, in Tcl

    return Tk(screenName, baseName, className, useTk)

  File "C:\Users\XXX\AppData\Local\Programs\Python\Python38\lib\tkinter\__init__.py", line 2256, in __init__

    baseName = os.path.basename(sys.argv[0])

  File "C:\Users\XXX\Desktop\capella_prova\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_collections.py", line 201, in __getitem__

    return self.__compute_item(key)

  File "C:\Users\XXX\Desktop\capella_prova\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_collections.py", line 177, in __compute_item

    new_key = self.__compute_index(key)

  File "C:\Users\XXX\Desktop\capella_prova\capella\plugins\py4j-python_0.10.9.5-bnd-2odeag\src\py4j\java_collections.py", line 174, in __compute_index

    raise IndexError("list index out of range")

IndexError: list index out of range

It seems there are some troubles with PySimpleGUI and tkinter. Are there any other documented cases like this one?

Thank you.

Regards

I never user this library myself… But from the error message I think some initialized path (or something else) produce an empty list where the code try to access expected indexes in this list. Look if you can do the initialization by providing the present working directory to the constructor. In short the way EASE start the script migth make sys.argv[] empty. Maybe an other way can be to initialize it yourself before calling the PySimpleGUI initiialization.