The Python Shell integration requires Python releases 3.7 onwards and the installation of Python.NET.
This image may be slightly different for your Python version, but always enable the options equivalent to:
Especially in the production server.
Note: For Python versions above 3.12, Pythonnet is not available. For more information, visit their documentation.
Python Interpreter | |
---|---|
Local | Defines the path of the Python installation folder on the local machine. |
Server | Defines the path of the Python installation folder on the remote server. |
Scripts Tasks and Classes
The Code Behind for the displays can be written in C#, VB.NET or JavaScript, not Python directly. But from the CodeBehind you can call tasks and methods, which can be written in Python.
This integration allows you to execute Python code from external files. Just create a Script Task with the following code:
# This code call the execution of the external file using Python Shell # with the optional args defined in this initial section # # The macro _ExecutionPath_ is replaced by the path where the solution is set to execute # Replace that macro by a specific path, or user other built-in macros as needed # arg1 = @Tag.Tag1 arg2 = @Tag.Tag2 result = TK.ExecutePythonShell("_ExecutionPath_ExternalSum.py", [arg1, arg2]) @Tag.Result = result
Python Shell Version and Tests
Any Python scripts you create in Scripts / Tasks can be edited and tested in Scripts / Code Editor. To test your script, click on [Monitor Icon] in the top toolbar. This will run your code and display messages in the Output Window, under the script editor.
This integration will work if your Python version is 3.7 or newer, with Python.NET installed, and the executable is correctly mapped in Solution / Settings.
→ Platform / Technology Foundation / Python and .NET Integration → Tutorials / Technology Learning / Python and .NET Integration → Technical Reference / Programming and APIs Reference / Python and .NET IntegrationPython and .NET Integration Links
Explanation - to understand concepts
Tutorials - to learn by doing
Reference - technical details