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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Puerts.Python.Complete" Version="3.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Puerts.Python.Complete" Version="3.0.1" />
                    
Directory.Packages.props
<PackageReference Include="Puerts.Python.Complete" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Puerts.Python.Complete --version 3.0.1
                    
#r "nuget: Puerts.Python.Complete, 3.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Puerts.Python.Complete@3.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Puerts.Python.Complete&version=3.0.1
                    
Install as a Cake Addin
#tool nuget:?package=Puerts.Python.Complete&version=3.0.1
                    
Install as a Cake Tool

PuerTS — Python for .NET

license Puerts.Python.Complete

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 ScriptEnv architecture 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-arm64 only.

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

BSD 3-Clause

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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