i ran python script from .net using IronPython, below is my python script
import tensorflow as tf
print('Tensorflow Imported')
below is the C # code
using System;
using System.Text;
using System.IO;
using IronPython.Hosting;
using System.Collections.Generic;
using Microsoft.Scripting.Hosting;
namespace ConsoleApplication1
{
class Program
{
private static void Main()
{
var py = Python.CreateEngine();
List<string> searchPaths = new List<string>();
searchPaths.Add(@"C:\Users\Admin\AppData\Local\Programs\Python\Python35\Lib)");
searchPaths.Add(@"C:\Users\Admin\AppData\Local\Programs\Python\Python35\Lib\site-packages)");
py.SetSearchPaths(searchPaths);
try
{
py.ExecuteFile("script.py");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}
below is my conclusion
Unexpected token 'out'
if I delete the import statement then the python script is executed. I tried to include os,syseverything that was imported without any problems. I installed TensorFlow via pip, when I run over the script through the python console (v3.5), it works fine.
: TF doc "TensorFlow 3.5.x Python Windows", IronPython - 2.7
IronPython GitHub, ( , !: D
- IronPython 2.7 Python .net?