Skip to content

Python Process ​

Python Process runs a Python script as a separate process. The panel shows the run status, duration, exit code, and output log. It suits helper scripts such as data processing or generating test data.

Each device window has its own Python run panel, and the panels do not affect each other. The panel only runs the script and shows its output. It does not send data to the serial port, and it does not pass received serial data to the script. If your script needs to read or write a serial port, the script must open the port itself. Keep in mind that SerialStudio may already have that port open.

Built-in Python environment ​

SerialStudio includes a portable Python 3.13.7 (Windows x64 embeddable package). Each time the program starts, it checks the SerialStudio\Python folder in your user folder, for example C:\Users\<username>\SerialStudio\Python:

  • If python.exe is already in the folder, the program does nothing.
  • If python.exe is missing, the program extracts the built-in portable package into the folder.

Only python.exe is checked

The program decides whether to extract only by checking whether python.exe exists. If other files in the folder are deleted or damaged, the program does not repair them. Close the program, delete the entire SerialStudio\Python folder, and start the program again.

At startup, the program also initializes the embedded Python environment from this folder. Changing the Python home setting below does not affect that embedded environment, which always stays in the default folder.

Finding the interpreter ​

When the panel runs a script, it determines the interpreter in this order:

  1. The Python home path in the Python group of the Settings window. After you change it, restart the program.
  2. If it is not set, the default folder SerialStudio\Python, which is where the built-in portable package is extracted.

In that folder, the panel looks for python.exe, python3.exe, and python, in that order. For each name, it checks the folder itself and then its Scripts subfolder. It uses the first interpreter it finds.

The system PATH is not used

If no interpreter is found, the panel shows "Run Error". The program does not read Python from the system PATH, so set Python home to the correct folder.

Third-party libraries ​

The built-in portable package does not include pip, and the site module is disabled by default. Libraries installed with pip into another location are therefore not found. To use third-party libraries, choose one of these options:

  • Copy the folder of a pure Python library into the root of SerialStudio\Python, the same level as python.exe.
  • Install a full copy of Python, set Python home in the Settings window to its root folder (which must contain python.exe), and restart the program. A full installation supports pip and site-packages normally.

Run a script ​

Click the Python Script button in the device window toolbar to open the panel. Then:

  1. Click Select and choose a .py script in the file dialog. The dialog remembers the last folder you used.
  2. Click Start Script. While the script runs, Start Script and Select are disabled.
  3. To end the run, click Stop Script.

The program runs the script as python -u <script path>. The -u option turns off output buffering, so print output appears in the log as it is produced.

Relative paths

The program does not set a working directory for the script. Relative paths in the script are resolved against SerialStudio's current working directory. Use absolute paths in your script when possible.

Run status ​

StatusMeaning
Not RunningThe script has not been started, or the panel was just opened
RunningThe script is running
CompletedThe script exited normally with exit code 0
ErrorThe exit code is not 0, the process crashed, the process could not start, or no interpreter was found
StoppedThe run was ended with Stop Script

If the script writes to standard error (stderr) while it runs, the status changes to "Error" first. If the script then exits with exit code 0, the status changes to "Completed".

The panel also shows:

  • Duration: Updated every 0.1 seconds during a run, in the format hours:minutes:seconds.
  • Exit code: The exit code when the script ends. After a manual stop, it shows -1.
  • Script file and Start time: The name of the current script and the time it started.

Log ​

Each log line has a timestamp and a type tag:

  • [INFO]: Standard output from the script, and status messages from the panel such as "Script started" or "Script finished".
  • [ERROR]: Standard error output from the script, such as exception tracebacks, and error messages from the panel.

The log keeps up to 10,000 lines. Older lines are removed when the limit is reached. The log is cleared automatically each time you start a script. Click Clear Log to clear it manually, or Save Log to save it as a text file.

Stop a script ​

Stop Script ends the process immediately. The script gets no chance to run cleanup code, such as closing files or disconnecting from a device, so data may be left incomplete. Closing the device window also ends any running script.

Notes ​

  • The panel does not provide standard input to the script. If the script calls input(), it waits forever, so avoid it.
  • Each panel runs one script at a time. To run scripts in parallel, start them from different device windows.