Puerts.Python.Complete
3.0.1
Prefix Reserved
dotnet add package Puerts.Python.Complete --version 3.0.1
NuGet\Install-Package Puerts.Python.Complete -Version 3.0.1
<PackageReference Include="Puerts.Python.Complete" Version="3.0.1" />
<PackageVersion Include="Puerts.Python.Complete" Version="3.0.1" />
<PackageReference Include="Puerts.Python.Complete" />
paket add Puerts.Python.Complete --version 3.0.1
#r "nuget: Puerts.Python.Complete, 3.0.1"
#:package Puerts.Python.Complete@3.0.1
#addin nuget:?package=Puerts.Python.Complete&version=3.0.1
#tool nuget:?package=Puerts.Python.Complete&version=3.0.1
PuerTS — Python for .NET
PuerTS is a scripting solution that brings Python (CPython) to your .NET applications. It provides seamless C# interop — using the same unified ScriptEnv API as the JavaScript and Lua backends. Great for AI/ML integration, tooling, and rapid prototyping.
Features
- 🐍 CPython Powered — Run real Python code with full CPython runtime.
- 🔗 Seamless C# Interop — Call any .NET type directly from Python, and invoke Python functions from C#.
- 🤖 AI/ML Ready — Ideal for integrating Python-based AI/ML libraries with .NET applications.
- 🔄 Unified API — Same
ScriptEnvarchitecture as JS and Lua backends — easy to switch or mix languages.
Installation
Install via NuGet. The Complete package includes core + native assets for all desktop platforms:
dotnet add package Puerts.Python.Complete
Or install components separately for finer control:
# Core library (required)
dotnet add package Puerts.Core
# Python backend
dotnet add package Puerts.Python
# Native assets per platform (choose what you need)
dotnet add package Puerts.Python.NativeAssets.Win32
dotnet add package Puerts.Python.NativeAssets.Linux
dotnet add package Puerts.Python.NativeAssets.macOS
Supported Platforms
.net8.0+, .netstandard2.1
| Windows (x64) | Linux (x64) | macOS (arm64) | |
|---|---|---|---|
| Python | ✔️ | ✔️ | ✔️ |
Note: The macOS native assets currently support
osx-arm64only.Note: AOT compilation is not currently supported.
Quick Start
using Puerts;
var env = new ScriptEnv(new BackendPython());
// Execute Python code
env.Eval("print('Hello from Python!')");
// Eval with return value
int result = env.Eval<int>("1 + 2");
Console.WriteLine($"Python result: {result}"); // output: 3
env.Dispose();
Multi-line Code
Python is indentation-sensitive. For multi-line code blocks, wrap with exec('''...'''):
var env = new ScriptEnv(new BackendPython());
env.Eval(@"
exec('''
def greet(name):
print('Hello, ' + name + '!')
greet('PuerTS')
''')
");
// output: Hello, PuerTS!
env.Dispose();
Calling C# from Python
Access .NET types via Python import:
import System.Console as Console
import System.DateTime as DateTime
# Call static methods
now = DateTime.Now
Console.WriteLine('Current time: ' + now.ToString())
# Create generic types
from System.Collections.Generic import List
lst = List[str]()
lst.Add('hello')
lst.Add('world')
Console.WriteLine('Count: ' + str(lst.Count))
Calling Python from C#
using Puerts;
using System;
var env = new ScriptEnv(new BackendPython());
// Get a Python lambda as a C# delegate
var add = env.Eval<Func<int, int, int>>("lambda a, b: a + b");
Console.WriteLine(add(10, 20)); // output: 30
// Define a function via exec, then retrieve it
env.Eval(@"
exec('''
def greet():
print('Hello from Python function!')
''')
");
var greet = env.Eval<Action>("greet");
greet(); // output: Hello from Python function!
env.Dispose();
Key Differences from JS/Lua
| Feature | JavaScript | Lua | Python |
|---|---|---|---|
| Environment creation | new ScriptEnv(new BackendV8()) |
new ScriptEnv(new BackendLua()) |
new ScriptEnv(new BackendPython()) |
| Console output | console.log(...) |
print(...) |
print(...) |
| Multi-line code | Write directly | Write directly | Wrap with exec('''...''') |
| Accessing C# types | CS.Namespace.Class |
require('csharp') |
import Namespace.Class |
| Instance method calls | obj.Method() |
obj:Method() |
obj.Method() |
| Null representation | null / undefined |
nil |
None |
Documentation
For full documentation, tutorials and API reference, visit: https://puerts.github.io/en
License
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Puerts.Core.Complete (>= 3.0.1)
- Puerts.Python (>= 3.0.1)
- Puerts.Python.NativeAssets.Linux (>= 3.0.1)
- Puerts.Python.NativeAssets.macOS (>= 3.0.1)
- Puerts.Python.NativeAssets.Win32 (>= 3.0.1)
-
net10.0
- Puerts.Core.Complete (>= 3.0.1)
- Puerts.Python (>= 3.0.1)
- Puerts.Python.NativeAssets.Linux (>= 3.0.1)
- Puerts.Python.NativeAssets.macOS (>= 3.0.1)
- Puerts.Python.NativeAssets.Win32 (>= 3.0.1)
-
net8.0
- Puerts.Core.Complete (>= 3.0.1)
- Puerts.Python (>= 3.0.1)
- Puerts.Python.NativeAssets.Linux (>= 3.0.1)
- Puerts.Python.NativeAssets.macOS (>= 3.0.1)
- Puerts.Python.NativeAssets.Win32 (>= 3.0.1)
-
net9.0
- Puerts.Core.Complete (>= 3.0.1)
- Puerts.Python (>= 3.0.1)
- Puerts.Python.NativeAssets.Linux (>= 3.0.1)
- Puerts.Python.NativeAssets.macOS (>= 3.0.1)
- Puerts.Python.NativeAssets.Win32 (>= 3.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.1 | 64 | 3/4/2026 |
| 3.0.0-beta1 | 286 | 12/15/2025 |