How to integrate Python with ASP.NET

11,085

If you don't need exactly python 3 - take a look at IronPython (latest version is 2.7 compatible). For example: Running IronPython Scripts from a C# 4.0 Program.
If you just need to use Python script from your your .NET project - you can just ask python.exe to run the script. Something like this:

ProcessStartInfo p = new ProcessStartInfo();
p.FileName = @"\Path\to\python\interpreter\python.exe";
p.Arguments = @"\Path\to\*.py";
p.CreateNoWindow = false;
p.UseShellExecute = true;
Process procScriptExecutor = Process.Start(p);
procScriptExecutor.WaitForExit();
procScriptExecutor.Close();
Share:
11,085
Admin
Author by

Admin

Updated on June 29, 2022

Comments

  • Admin
    Admin almost 2 years

    I am making an ASP.NET website in which I would like to use some python 3.x code. Not exactly 'some', but a lot.

    I have started searching for a solution but not exactly reached a good one yet. I am using VS 2015, and most of the solutions I found were for VS 2010, 2012. But not for VS 2015.

    So I began with installing the PTVS, but that ends up in an error. Screenshot of error.

    Please help regarding the installation error and how to set up the integration.

    Thanks a bunch.