Python.Included 3.13.1

dotnet add package Python.Included --version 3.13.1
                    
NuGet\Install-Package Python.Included -Version 3.13.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="Python.Included" Version="3.13.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Python.Included" Version="3.13.1" />
                    
Directory.Packages.props
<PackageReference Include="Python.Included" />
                    
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 Python.Included --version 3.13.1
                    
#r "nuget: Python.Included, 3.13.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 Python.Included@3.13.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=Python.Included&version=3.13.1
                    
Install as a Cake Addin
#tool nuget:?package=Python.Included&version=3.13.1
                    
Install as a Cake Tool

logo

Python.Included

Python.Included is an automatic deployment mechanism for .NET packages which depend on the embedded Python distribution. This allows libraries depending on Python and/or Python packages to be deployed via Nuget without having to worry about any local Python installations.

It packages embedded Python (python-3.13.0-embed-amd64.zip) in its .NET assembly and automatically deploys it in the user's home directory upon first execution. On subsequent runs, it will find Python already deployed and therefor doesn't install it again. It also features a Python package (*.whl) installer which Numpy.NET uses to install the NumPy wheel into the embedded Python installation. Last but not least, for packages that are too big to package into .NET nugets, there is support for installing those with pip.

Note: Python.Included only implements deployment on top of pythonnet_netstandard. If you do not need (or want) the automatic deployment of embedded Python you should use that.

Getting Started

Just reference Python.Included via NuGet, call await Installer.SetupPython(); and you are ready to interop with Python.NET. It is completely irrelevant wether or not you have any local Python installations of any kind.

This short example initializes Python.Included and prints the version of the included Python installation by calling Python's sys.version:

using System;
using System.Threading.Tasks;
using Python.Included;
using Python.Runtime;

namespace NetCoreExample
{
    class Program
    {
        static async Task Main(string[] args)
        {
            await Installer.SetupPython();
            PythonEngine.Initialize();
            dynamic sys = Py.Import("sys");
            Console.WriteLine("Python version: " + sys.version);
        }
    }
}

Output (may differ due to updated Python version):

Python version: 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]

Installing Python libraries (*.whl files) from embedded resources

An example of this usage is Numpy.NET which in np.module.gen.cs installs the numpy binary which it includes as embedded resource:

await Installer.SetupPython(force)
await Installer.InstallWheel(typeof(np).Assembly, "numpy-1.16.3-cp37-cp37m-win_amd64.whl")
PythonEngine.Initialize();
var numpy = Py.Import("numpy");

Installer.InstallWheel(Assembly assembly, string resource_name) loads the wheel from the given assembly and installs it into the embedded python installation.

NOTE: Make sure the wheel file is compatible to the version of Python which Python.Included installs (v3.7.3 x64). Also, while it works fine with numpy, not every python package can easily be embedded due to its size. Some might require extra installation routines which are not supported by InstallWheel. In that case, use pip to download and install such packages as described below.

Installing Python libraries with pip

You can install a current version of pip3 and use that to install any python package:

await Installer.SetupPython();
await Installer.TryInstallPip();
await Installer.PipInstallModule("spacy");
PythonEngine.Initialize();
dynamic spacy = Py.Import("spacy");
Console.WriteLine("Spacy version: " + spacy.__version__);

Check out the example project TestPipInstallation to try it out.

Project Status

The code is stable for Windows. For testing on other platforms help is wanted.

Projects using Python.Included

License

Since Python.Included distributes Python, it is licensed under the Python Software Foundation License (PSF) like Python itself.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (8)

Showing the top 5 NuGet packages that depend on Python.Included:

Package Downloads
Numpy

C# bindings for NumPy - a fundamental library for scientific computing, machine learning and AI. Does not require a local Python installation!

Catalyst.Spacy

Integration for Catalyst to run spaCy models from C#.

CuPy.NET

CuPy.NET is a wrapper library for CuPy in Python.

Cringules.NGram.Lib

Package Description

Rays.Core.Script

Package Description

GitHub repositories (6)

Showing the top 6 popular GitHub repositories that depend on Python.Included:

Repository Stars
open-rpa/openrpa
Free Open Source Enterprise Grade RPA
killkimno/MORT
MORT 번역기 프로젝트 - Real-time game translator with OCR
curiosity-ai/catalyst
🚀 Catalyst is a C# Natural Language Processing library built for speed. Inspired by spaCy's design, it brings pre-trained models, out-of-the box support for training word and document embeddings, and flexible entity recognition models.
SciSharp/Numpy.NET
C#/F# bindings for NumPy - a fundamental library for scientific computing, machine learning and AI
LegacyGwent/LegacyGwent
复刻巫师之昆特牌的内测版本
nicolasdeory/firelight
A modular game integration for Razer Chroma and other RGB LED devices for League of Legends, Rocket League, Fortnite and many more.
Version Downloads Last Updated
3.13.1 76 2/23/2026
3.13.0 2,490 9/1/2025
3.11.6 46,206 11/25/2023
3.11.4 15,455 7/14/2023
3.11.3 1,122 7/6/2023
3.11.2 45,481 3/8/2023
3.11.1 76,779 12/11/2022
3.11.0 846 12/11/2022 3.11.0 is deprecated because it has critical bugs.
3.10.0-preview5 4,209 6/24/2022
3.10.0-preview4 399 6/23/2022
3.10.0-preview3 430 6/23/2022
3.10.0-preview2 26,649 5/31/2022
3.10.0-preview1 612 2/13/2022
3.7.3.13 131,710 9/16/2020
3.7.3.12 961 9/7/2020
3.7.3.11 759 9/4/2020
3.7.3.10 2,384 8/4/2020
3.7.3.9 2,823 8/3/2020
3.7.3.8 617 7/31/2020
Loading failed