[OpenR8 solution] Python (Execute a Python program)
  1. Chapter1: Python introduction

 

The Python function is used to execute the python file. Just select the specified python file, fill in the parameters you want to pass to the python file, and press the run execution flow file to get the string returned by python. The flow is shown in Fig. 1.

 

Fig. 1. Python flowchart.png

Fig. 1. Python flowchart.

 

 

  1. Chapter2: Python folder introduction

 

Python is located in the solution folder of OpenR8, as shown in Fig. 2, with three flow files and a src folder, as shown in Fig. 3.

 

Fig. 2. Python location.png

Fig. 2. Python location.

 

Fig. 3. Python folder.png

Fig. 3. Python folder.

 

 

  1. Chapter3: callPython.flow — run example.py 

 

Please double-click “R8_Python3.6_CPU.bat or R8_Python3.6_GPU.bat” => “File” => “Open” => “Enter the solution under OpenR8” => “Select Python folder” => “Load callPython.flow”, as shown in Fig. 4, Fig. 5.

 

Fig. 4. Select callPython.flow.png

Fig. 4. Select callPython.flow.

 

Fig. 5. Load callPython.flow.png

Fig. 5. Load callPython.flow.

 

Press Run to see the process and results of [example.py] execution, as shown in Fig. 6 and Fig. 7.

 

Fig. 6. Result.png

Fig. 6. Result.

 

Fig. 7. Running results and example.py.png

Fig. 7. Running results and example.py.

 

It can be seen from Fig. 7 that if the print() function is used in the python file,

 

  1. Green line (light green, dark green): will be printed in the DOS window.
  2. Orange line: The symbol "$" is added to the front and back, and will be passed back to R8.

 

 

  1. Chapter4: checkIsPythonInstalled.flow — Confirm if Python is installed 

 

Please double-click “R8_Python3.6_CPU.bat or R8_Python3.6_GPU.bat” => “File” => “Open” => “Enter the solution under OpenR8” => “Select Python folder” => “Load checkIsPythonInstalled.flow”, as shown in Fig. 8, Fig. 9.

 

Fig. 8. Select checkIsPythonInstalled.flow.png

Fig. 8. Select checkIsPythonInstalled.flow.

 

Fig. 9. Open checkIsPythonInstalled.flow.png

Fig. 9. Open checkIsPythonInstalled.flow.

 

Press Run to see if the result of installing python is displayed, as shown in Fig. 10, Fig. 11.

 

Fig. 10. Execution results of the installation.png

Fig. 10. Execution results of the installation.

 

Fig. 11. Execution results without installation.png

Fig. 11. Execution results without installation.

 

 

  1. Chapter5: checkIsTensorflowInstalled.flow — Confirm if Tensorflow is installed

 

Please double-click “R8_Python3.6_CPU.bat or R8_Python3.6_GPU.bat” => “File” => “Open” => “Enter the solution under OpenR8” => “Select Python folder” => “Load checkIsTensorflowInstalled.flow”, as shown in Fig. 12, Fig. 13.

 

Fig. 12. Select checkIsTensorflowInstalled.flow.png

Fig. 12. Select checkIsTensorflowInstalled.flow.

 

Fig. 13. Load checkIsTensorflowInstalled.flow.png

Fig. 13. Load checkIsTensorflowInstalled.flow.

 

Press Run to see if Tensorflow is installed, as shown in Fig. 14,Fig. 15.

 

Fig. 14. Execution results with Tensorflow installed.png

Fig. 14. Execution results with Tensorflow installed.

 

Fig. 15. Execution results without Tensorflow installed.png

Fig. 15. Execution results without Tensorflow installed.

 

 

  1. Chapter6: Python function introduction

 

Fig. 16. Python function.png

Fig. 16. Python function.

 

  1. result: Receive the string returned by python. Please refer to Fig. 7 for the orange line section for the python file return string.
  2. path: The python file to be executed.
  3. arg: Parameters: Parameters to be passed to the python file (multiple parameters are separated by spaces).
  4. pythonPath: the path to python.exe (usually not required).

 

 


Recommended Article

1.
OpenR8 - AI Software for Everyone (Download)