run python script from unity

Solutions on MaxInterview for run python script from unity by the best coders in the world

showing results for - "run python script from unity"
Kayleigh
24 May 2019
1Instead 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.
2
3To use it you need to download the compiled binaries from http://ironpython.net/download/
4
5Then copy all the required assemblies in your resources folder:
6
7IronPython.dll
8IronPython.Modules.dll
9Microsoft.Scripting.Core.dll
10Microsoft.Scripting.dll
11Microsoft.Scripting.Debugging.dll
12Microsoft.Scripting.ExtensionAttribute.dll
13Microsoft.Dynamic.dll
14Then you will have access to the Python Engine, you can initialize it as follows:
15
16PythonEngine engine = new PythonEngine();  
17engine.LoadAssembly(Assembly.GetAssembly(typeof(GameObject)));         
18engine.ExecuteFile("Project1.py");
19You can see more info here: http://ironpython.net/documentation/
20
21References
22
23http://shrigsoc.blogspot.com.es/2016/07/ironpython-and-unity.html https://forum.unity.com/threads/ironpython-in-unity-a-good-idea.225544/