Simcenter Amesim Simcenter Amesim: Update scripts and apps from Python 2.X to Python 3

Simcenter Amesim Automation Connect Simcenter System Simulation Client for Git Simcenter Amesim Teamcenter Share


Starting from Simcenter Amesim 2019.2 the python distribution bundled within the installation has been switched to Python 3. This page explains how to deal with this change and make your Python scripts compatible with Simcenter Amesim that uses Python 3.


To find the complete information about the changes in Python 3.x, you can read the "What's new" page for each release of Python 3 and the Porting to Python 3 book.

Running migration script

A migration script is provided in Simcenter Amesim (located in $AME/scripting/python) to help porting Python scripts to Python 3 (the script internally uses the lib2to3 library).

usage: [-h] [--no-backup] [--logfile [FILE]] [-v] path

The path argument can be either a directory, a Python script or an App file (*.app).

--no-backup: Disable the file backup. By default, a backup of the original file is done.
--logfile <file>: Create a log file with the given filename (no log file by default).
-v, --verbose: Increase the verbosity. When enabled, it will log more information (disabled by default).

Here is a basic example of porting the content of python_scripts directory recursively, and logging conversion outputs into migration_log.txt file:

python -m python3_migration --logfile migration_log.txt python_scripts

Migrating App

In Simcenter Amesim, when editing an App created in a previous version in App Designer, the user is asked whether he wants to automatically convert the code to Python 3.
User-added image
By answering "Yes", the App Designer will execute automatically the migration script on the App Python scripts. The user can also consider to convert his code manually by discarding the automatic migration.

KB Article ID# KB000045189_EN_US



Associated Components

Amesim Automation Connect