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)) 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");
dynamic sin = np.sin;
Console.WriteLine(np.cos(np.pi*2));
Console.WriteLine(sin(5));
double c = np.cos(5) + sin(5);
Console.WriteLine(c);
/* this block is temporarily disabled due to regression
dynamic a = np.array(new List<float> { 1, 2, 3 });
dynamic b = np.array(new List<float> { 6, 5, 4 }, Py.kw("dtype", np.int32));
Console.WriteLine(a.dtype);
Console.WriteLine(b.dtype);
Console.WriteLine(a * b); */
Console.ReadKey();
}
}
Output:
1.0
-0.958924274663
-0.6752620892
float64
int32
[6. 10. 12.]
Metadata
Release files for pythonnet 2.2.2
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.2.2.tar.gz | 1.5 MB | Without provenance | Details |
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| pythonnet-2.2.2-cp36-cp36m-win_amd64.whl | CPython 3.6 | CPython 3.6 pymalloc | Windows x86-64 | Details |
| pythonnet-2.2.2-cp36-cp36m-win32.whl | CPython 3.6 | CPython 3.6 pymalloc | Windows x86-32 | Details |
| pythonnet-2.2.2-cp35-cp35m-win_amd64.whl | CPython 3.5 | CPython 3.5 pymalloc | Windows x86-64 | Details |
| pythonnet-2.2.2-cp35-cp35m-win32.whl | CPython 3.5 | CPython 3.5 pymalloc | Windows x86-32 | Details |
| pythonnet-2.2.2-cp34-cp34m-win_amd64.whl | CPython 3.4 | CPython 3.4 pymalloc | Windows x86-64 | Details |
| pythonnet-2.2.2-cp34-cp34m-win32.whl | CPython 3.4 | CPython 3.4 pymalloc | Windows x86-32 | Details |
| pythonnet-2.2.2-cp33-cp33m-win_amd64.whl | CPython 3.3 | CPython 3.3 pymalloc | Windows x86-64 | Details |
| pythonnet-2.2.2-cp33-cp33m-win32.whl | CPython 3.3 | CPython 3.3 pymalloc | Windows x86-32 | Details |
| pythonnet-2.2.2-cp27-cp27m-win_amd64.whl | CPython 2.7 | CPython 2.7 pymalloc | Windows x86-64 | Details |
| pythonnet-2.2.2-cp27-cp27m-win32.whl | CPython 2.7 | CPython 2.7 pymalloc | Windows x86-32 | Details |
Total release size: 2.1 MB
Release files / pythonnet-2.2.2.tar.gz
| Download URL | pythonnet-2.2.2.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ea51b14a286eb54d5a71c7e2a408c59ba028418585e393732617518caf1a0d8
|
|
BLAKE2b-256 checksum How to use checksums |
82852db5319e610c8f2568bbd81c0e46fc39a0bfb44c2990e6b9b4dfc9b8e6b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp36-cp36m-win_amd64.whl
| Download URL | pythonnet-2.2.2-cp36-cp36m-win_amd64.whl |
|---|---|
| Size | 57.3 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5f712361625d0634e6fc75576e2dd0d3801ff99788901cc84742d2265c18a740
|
|
BLAKE2b-256 checksum How to use checksums |
8bf0218609355ebea8848f666796bb8f886d5bf6205834c86a9e2118f6089d44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp36-cp36m-win32.whl
| Download URL | pythonnet-2.2.2-cp36-cp36m-win32.whl |
|---|---|
| Size | 57.4 kB |
| Tags | CPython 3.6 CPython 3.6 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
46c1c4210e812e9c09bf9a4ca10fe9e9e4801054030eb17b40082c86c72c2fea
|
|
BLAKE2b-256 checksum How to use checksums |
f4063ff886bf7dc9ef45751ccf224e95e686f4534b1792abce9143769f11e1cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp35-cp35m-win_amd64.whl
| Download URL | pythonnet-2.2.2-cp35-cp35m-win_amd64.whl |
|---|---|
| Size | 57.3 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
47f9047d55c43ee5a39d18ea6daeedbeebe28add74ac90b08b7b6c66b05d1f38
|
|
BLAKE2b-256 checksum How to use checksums |
c21b616ba08a2856537f511e052020dc2317213af031d88c8db361f26cc89f6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp35-cp35m-win32.whl
| Download URL | pythonnet-2.2.2-cp35-cp35m-win32.whl |
|---|---|
| Size | 57.4 kB |
| Tags | CPython 3.5 CPython 3.5 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
59f6cfe980ab112dc512632d4271d1a7d86758809ab3e19d6ed5b81613fa67ca
|
|
BLAKE2b-256 checksum How to use checksums |
efb30694741489285bafdcd8dcf105e26c3701c59cb9f0fbc274d007895d8bb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp34-cp34m-win_amd64.whl
| Download URL | pythonnet-2.2.2-cp34-cp34m-win_amd64.whl |
|---|---|
| Size | 57.3 kB |
| Tags | CPython 3.4 CPython 3.4 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b75585bcdd478b3366735ad43035b2ae9a12a499dd02e4c9a9b575c071a40509
|
|
BLAKE2b-256 checksum How to use checksums |
fecf91c27d239c07a3acc5ce4c483efc3e08c0608f9fd2b184dfc624e851ed33
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp34-cp34m-win32.whl
| Download URL | pythonnet-2.2.2-cp34-cp34m-win32.whl |
|---|---|
| Size | 57.4 kB |
| Tags | CPython 3.4 CPython 3.4 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
340bb436bb7f65c6b014556dde14d2485cbe21e6b6b76182ea99664bc57cf218
|
|
BLAKE2b-256 checksum How to use checksums |
19e099b424867423ef2df3ce6f93345eff94fab7a05fee8c8f568c7fbf6b6599
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp33-cp33m-win_amd64.whl
| Download URL | pythonnet-2.2.2-cp33-cp33m-win_amd64.whl |
|---|---|
| Size | 57.3 kB |
| Tags | CPython 3.3 CPython 3.3 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
d11819876b4d7db7232b4080f655ee1d446a96fb2d30e53e92d302c9589c3380
|
|
BLAKE2b-256 checksum How to use checksums |
464fb34d4f318b604bb54fab34ff7d22edb67057ca14bc79aa9defe6e5a9c497
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp33-cp33m-win32.whl
| Download URL | pythonnet-2.2.2-cp33-cp33m-win32.whl |
|---|---|
| Size | 57.4 kB |
| Tags | CPython 3.3 CPython 3.3 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
31e162ff1c6ba153924b5d59077bc1430c795a8bb5198695f2a31cc5d3a42363
|
|
BLAKE2b-256 checksum How to use checksums |
48356386e840d73222fe434f9c7231661c323f676bc0302546c07daf426c87f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp27-cp27m-win_amd64.whl
| Download URL | pythonnet-2.2.2-cp27-cp27m-win_amd64.whl |
|---|---|
| Size | 56.4 kB |
| Tags | CPython 2.7 CPython 2.7 pymalloc Windows x86-64 |
|
SHA-256 checksum How to use checksums |
82460185b3c7a77bfc7f7102646f626e1eea9c6060284f62751074cac02a49be
|
|
BLAKE2b-256 checksum How to use checksums |
67ba3a092b33bec769763595b7a7ddab6a810d20714760f2a2bd7b4a4aaeafe3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / pythonnet-2.2.2-cp27-cp27m-win32.whl
| Download URL | pythonnet-2.2.2-cp27-cp27m-win32.whl |
|---|---|
| Size | 56.5 kB |
| Tags | CPython 2.7 CPython 2.7 pymalloc Windows x86-32 |
|
SHA-256 checksum How to use checksums |
2de76d9a1071797eccc2316e43828a2dbd6406239037c0d868ea9f2f1201ba0f
|
|
BLAKE2b-256 checksum How to use checksums |
170b0acd22b71f846ef7ae7b790ece43c1690c21e018256f38f7b257dab096f5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pythonnet 2.2.2
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.