1 Run Python in Origin


Running Python Inside Origin

Origin supports embedded Python versions 3.7.2 and 2.7. By default, it is Python version 3.7.2 running in Origin.

  1. To switch to Python version 2.7, set LabTalk system variable @PYV= 2.


For information on setting the value of a LabTalk system variable, see this FAQ.

Run Python Command in Console

To run Python in the Python Console:

  1. Click Connectivity:Python Console....
  2. You can execute Python commands directly in the Python Console. For instance, at the prompt, you can type ...
help('modules')

... to see which packages have been installed.

Hello World Example

In this simple example, we will save our script to a .py file and execute the script from Origin's Script Window.

  1. From the Origin menu, choose View: Code Builder (ALT + 4).
  2. From the Code Builder menu, choose File: New and choose Python File.
  3. Give the file a name (e.g. "Hello.py"), then in the panel to the upper-right, enter the following:
  4. print ("Hello World!")
  5. Choose File: Save and save the file to your User Files Folder.
  6. Close Code Builder, then from the Origin menu choose Window: Script Window (Shift + ALT + 3).
  7. In the Script Window, type the following and press Enter:
    run -pyf "Hello.py"

The message "Hello World!" is returned to the Script Window (see run -pyf).

Installing a Package

For information on installing packages in embedded Python, see this blog post.