Skip to content

Latest commit

History

History
83 lines (68 loc) · 1.46 KB

File metadata and controls

83 lines (68 loc) · 1.46 KB


PythonShell.NET

Python Environment Manager and Executor for .NET


Available for:

  • net5.0, net6.0

Supported Platforms:

  • Windows 10+ (x86, amd64, arm64)
  • Linux Distos (amd64, arm64)
  • OSX 11+ (amd64, arm64)




Install

dotnet add package PythonShell.NET



Usage

  • basic usage
usingPythonShell.Listener;usingPythonShell.Shell;varshell=newPythonShell.PythonShell(newPythonShell.PythonShellConfig());awaitshell.Initialize();shell.RunString("{pythonCode}");
  • use instance
usingPythonShell.Listener;usingPythonShell.Shell;newPythonShell.PythonShell(newPythonShell.PythonShellConfig()).Initialize();varinstance=ShellManager.GetInstance("default");instance.RunString("{pythonCode}");

  • onMessage, onError, onComplete
// setups like above ...shell.RunString("{pythonCode}",listener:ShellListener{OnMessage=(message){// if `echo` is `true`, log to console automaticallyConsole.WriteLine("message!");},OnError=(e){Console.WriteLine(e.Data);},OnComplete=(){Console.WriteLine("complete!");}});

for further informations, refers to PythonShell.cs