Skip to content

eseunghwan/PythonShell.NET

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


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
using PythonShell.Listener;
using PythonShell.Shell;

var shell = new PythonShell.PythonShell(
    new PythonShell.PythonShellConfig()
);
await shell.Initialize();

shell.RunString("{pythonCode}");
  • use instance
using PythonShell.Listener;
using PythonShell.Shell;

new PythonShell.PythonShell(
    new PythonShell.PythonShellConfig()
).Initialize();

var instance = 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 automatically
            Console.WriteLine("message!");
        },
        OnError =  (e) {
            Console.WriteLine(e.Data);
        },
        OnComplete = () {
            Console.WriteLine("complete!");
        }
    }
);

for further informations, refers to PythonShell.cs

About

Python Environment Manager and Executor for .NET

Resources

License

Stars

Watchers

Forks

Packages

No packages published