i was running python script from .net using IronPython, below is my python script
import tensorflow as tf
print('Tensorflow Imported')
below is 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 output
Unexpected token 'from'
if i remove import statement then python script executes fine. I tried including os,sys all those were imported without any issue. I have installed TensorFlow via pip, when i run above script through python console(v3.5) it works fine.
Update: in TF doc its written "TensorFlow only supports version 3.5.x of Python on Windows". but official release of IronPython is version 2.7 I was happy to find IronPython on GitHub, tried building it (i just typed build in console and got freaked out with the long list of error messages it showed! :D couldn't find pre-compiled binaries
is there any alternative way to import tensorflow in IronPython 2.7 or run Python in .net?
searchPath. my goal is to run python within .net. is ther any alternative way to do this? Thanks - Prakash M