This release is a pre-release and may not be stable for production use.
pythonnet - Python for .NET
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers. It allows Python code to interact with the CLR, and may also be used to embed Python into a .NET application.
Calling .NET code from Python
Python for .NET allows CLR namespaces to be treated essentially as Python packages.
import clr
from System import String
from System.Collections import *
To load an assembly, use the AddReference function in the clr module:
import clr
clr.AddReference("System.Windows.Forms")
from System.Windows.Forms import Form
Embedding Python in .NET
All calls to python should be inside a using (Py.GIL()) {/* Your code here */} block.
Import python modules using dynamic mod = Py.Import("mod"), then you can call functions as normal, eg mod.func(args).
Use mod.func(args, Py.kw("keywordargname", keywordargvalue)) or mod.func(args, keywordargname: keywordargvalue) to apply keyword arguments.
All python objects should be declared as dynamic type.
Mathematical operations involving python and literal/managed types must have the python object first, eg. np.pi * 2 works, 2 * np.pi doesn’t.
Example
static void Main(string[] args)
{
using (Py.GIL())
{
dynamic np = Py.Import("numpy");
Console.WriteLine(np.cos(np.pi * 2));
dynamic sin = np.sin;
Console.WriteLine(sin(5));
double c = np.cos(5) + sin(5);
Console.WriteLine(c);
dynamic a = np.array(new List<float> { 1, 2, 3 });
Console.WriteLine(a.dtype);
dynamic b = np.array(new List<float> { 6, 5, 4 }, dtype: np.int32);
Console.WriteLine(b.dtype);
Console.WriteLine(a * b);
Console.ReadKey();
}
}
Output:
1.0
-0.958924274663
-0.6752620892
float64
int32
[ 6. 10. 12.]
Information on installation, FAQ, troubleshooting, debugging, and projects using pythonnet can be found in the Wiki:
Metadata
Release files for pythonnet 2.4.0rc2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pythonnet-2.4.0rc2.tar.gz | 1.8 MB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pythonnet-2.4.0rc2-cp37-cp37m-win_amd64.whl | CPython 3.7 | CPython 3.7 pymalloc | Windows x86-64 | Details |
| pythonnet-2.4.0rc2-cp37-cp37m-win32.whl | CPython 3.7 | CPython 3.7 pymalloc | Windows x86-32 | Details |
| pythonnet-2.4.0rc2-cp36-cp36m-win_amd64.whl | CPython 3.6 | CPython 3.6 pymalloc | Windows x86-64 | Details |
| pythonnet-2.4.0rc2-cp36-cp36m-win32.whl | CPython 3.6 | CPython 3.6 pymalloc | Windows x86-32 | Details |
| pythonnet-2.4.0rc2-cp35-cp35m-win_amd64.whl | CPython 3.5 | CPython 3.5 pymalloc | Windows x86-64 | Details |
| pythonnet-2.4.0rc2-cp35-cp35m-win32.whl | CPython 3.5 | CPython 3.5 pymalloc | Windows x86-32 | Details |
| pythonnet-2.4.0rc2-cp27-cp27m-win_amd64.whl | CPython 2.7 | CPython 2.7 pymalloc | Windows x86-64 | Details |
| pythonnet-2.4.0rc2-cp27-cp27m-win32.whl | CPython 2.7 | CPython 2.7 pymalloc | Windows x86-32 | Details |
Total release size: 2.4 MB
Release files / pythonnet-2.4.0rc2.tar.gz
| Download URL | pythonnet-2.4.0rc2.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a1d6234a056bcc0f6d35a6fedf62ab867a7548ed166b976fcdaf38fb9ec252bf
|
|
BLAKE2b-256 checksum How to use checksums |
ef9527ad1e3a52f8ea60b4a6bceeb56c57a89c47ada370b69467c15e476abb56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / pythonnet-2.4.0rc2-cp37-cp37m-win_amd64.whl
| Download URL | pythonnet-2.4.0rc2-cp37-cp37m-win_amd64.whl |
|---|---|
| Size | 71.2 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d21afbc8aa91bd8bc217850039a5c66934a84bb853c385a0be077228c5fee24a
|
|
BLAKE2b-256 checksum How to use checksums |
65d60843db01800b829e634a8ea4f3c3c0aa5895a78d5ad51bb44fda90561bed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / pythonnet-2.4.0rc2-cp37-cp37m-win32.whl
| Download URL | pythonnet-2.4.0rc2-cp37-cp37m-win32.whl |
|---|---|
| Size | 71.2 kB |
| Tags | CPython 3.7 CPython 3.7 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
a8495cd2b59ce6dffbda6799adb1713ebc69e5432d1117eca8002ba0c48894f5
|
|
BLAKE2b-256 checksum How to use checksums |
f923efbb4dd0641f922e2ee30ce390a4b77b0835b7bc02d70281e8928964cd8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / pythonnet-2.4.0rc2-cp36-cp36m-win_amd64.whl
| Download URL | pythonnet-2.4.0rc2-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 71.2 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a781ce14c04775cf6e7ebc004d31e9cecf7a6aa52a4849efdbf09b9048ae6dcd
|
|
BLAKE2b-256 checksum How to use checksums |
1e7bf95a07ba8fa9e43de2f26d161451d9184ef767f8248beffdf73cc1e03f6c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / pythonnet-2.4.0rc2-cp36-cp36m-win32.whl
| Download URL | pythonnet-2.4.0rc2-cp36-cp36m-win32.whl |
|---|---|
| Size | 71.2 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
b1abcbaf994b1bf88402fd786840e1055c57311ecb7d8fc0f4e52ae88bef713a
|
|
BLAKE2b-256 checksum How to use checksums |
94d731f9c00c5356da856d61890dfad78a82b906039662ba8894b02a0c722fbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / pythonnet-2.4.0rc2-cp35-cp35m-win_amd64.whl
| Download URL | pythonnet-2.4.0rc2-cp35-cp35m-win_amd64.whl |
|---|---|
| Size | 71.2 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a54ffa85c0efd5ba57b13cc4736af19ee1711a74f73e05bae75d1569b50e0117
|
|
BLAKE2b-256 checksum How to use checksums |
08c6a4f3a41f4ab5c76a96edee24750504f28dea6e8bee03313e90b02f729ea1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / pythonnet-2.4.0rc2-cp35-cp35m-win32.whl
| Download URL | pythonnet-2.4.0rc2-cp35-cp35m-win32.whl |
|---|---|
| Size | 71.2 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
52886e820ed2f6ae60762e8e378b9b41fb83a5beeb81c5c1e6b803eb59004c9f
|
|
BLAKE2b-256 checksum How to use checksums |
42825e46ae63484bf1f5e49a8d74d31d67c5959019f36bd89f6a141008c669aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / pythonnet-2.4.0rc2-cp27-cp27m-win_amd64.whl
| Download URL | pythonnet-2.4.0rc2-cp27-cp27m-win_amd64.whl |
|---|---|
| Size | 70.8 kB |
| Tags | CPython 2.7 CPython 2.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2acfe12463b98c9fd1f760d44895caa725d107107de2de9d64246958eb7cbbe4
|
|
BLAKE2b-256 checksum How to use checksums |
f0c01d449e3af72081dab39bb7931e2d74f09c8094c53746c2a93a56fa87f2f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Release files / pythonnet-2.4.0rc2-cp27-cp27m-win32.whl
| Download URL | pythonnet-2.4.0rc2-cp27-cp27m-win32.whl |
|---|---|
| Size | 70.8 kB |
| Tags | CPython 2.7 CPython 2.7 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
3e490ee8199c7c97d624cf145de3dd5588bece2a456920ff9f79f74e12e31998
|
|
BLAKE2b-256 checksum How to use checksums |
1786d6616347e3adacf88f010df9ac5aec4fc3e88d3ad7d40fbb7fc3f3894dc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
|
Security for pythonnet 2.4.0rc2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.