Run a python script from unity, to use its output (text file) in my game later

I'm trying to run a python script from unity (C# script) to use its output which is a text file in my game later, the thing is that when I run the C# script in unity nothing happens (Python script works fine on its own). Can anyone tell me what I'm missing? Thanks.

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.IO;
using UnityEngine.UI;
using System.Text.RegularExpressions;
using System.Diagnostics;

using System.Runtime.InteropServices;
public class PyCx : MonoBehaviour {
    public Text Message;
    public GameObject OpenPanel1 = null;
    // Use this for initialization
    void Start () {
        python ();
        read ();
        ShowMessage ();
    public void python(){
        ProcessStartInfo pythonInfo = new ProcessStartInfo ();
        Process python;
        pythonInfo.CreateNoWindow = false;
        pythonInfo.UseShellExecute = false;
        python = Process.Start (pythonInfo);
        python.WaitForExit ();
        python.Close ();
    public void read(){
        using (var reader = new StreamReader ("C://Users//HP//Documents//result.txt")) {
            string line = reader.ReadToEnd ();
            Message.text = (line);
    public void ShowMessage(){
        OpenPanel1.SetActive (true);
        Message.IsActive ();
    // Update is called once per frame
    void Update () {



Instead of using a process which can be unreliable outside your controlled development environment (you don't know if your users will even have Python installed and which version) you could try to run Python directly in your code using IronPython, IronPython is a Python interpreter for the CLR so it doesn't even require Python to be installed to execute your scripts.

To use it you need to download the compiled binaries from

Then copy all the required assemblies in your resources folder:

  • IronPython.dll
  • IronPython.Modules.dll
  • Microsoft.Scripting.Core.dll
  • Microsoft.Scripting.dll
  • Microsoft.Scripting.Debugging.dll
  • Microsoft.Scripting.ExtensionAttribute.dll
  • Microsoft.Dynamic.dll

Then you will have access to the Python Engine, you can initialize it as follows:

PythonEngine engine = new PythonEngine();  

You can see more info here: