how to run python in unity code example

Example 1: Use Unity With Python

pip install pyside

Example 2: run python script from unity

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 http://ironpython.net/download/

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();  
engine.LoadAssembly(Assembly.GetAssembly(typeof(GameObject)));         
engine.ExecuteFile("Project1.py");
You can see more info here: http://ironpython.net/documentation/

References

http://shrigsoc.blogspot.com.es/2016/07/ironpython-and-unity.html https://forum.unity.com/threads/ironpython-in-unity-a-good-idea.225544/