Questions tagged [pythonnet]

Python for .NET (pythonnet) is a package that gives Python developers an integration with .NET 4.0+ Common Language Runtime (CLR) on Windows and Mono runtime on Linux and OSX. Python for .NET provides a powerful application scripting tool for .NET developers. Using this package you can script .NET applications in Python or build applications in Python, using .NET components written in languages that target CLR (C#, VB.NET, F#). http://pythonnet.github.io

Python for .NET (pythonnet) is a package that gives Python developers an integration with .NET 4.0+ Common Language Runtime (CLR) on Windows and Mono runtime on Linux and OSX. Python for .NET provides a powerful application scripting tool for .NET developers. Using this package you can script .NET applications in Python or build applications in Python, using .NET components written in languages that target CLR (C#, VB.NET, F#).

Note that this package does not implement Python as a first-class CLR language - it does not produce managed code (IL) from Python code. Rather, it is an integration of the CPython engine with the .NET or Mono runtime. This approach allows you to use CLR services and continue to use existing Python code and C-API extensions while maintaining native execution speeds for Python code. If you are interested in a pure managed-code implementation of the Python language, you should check out the IronPython project, which is in active development.

http://pythonnet.github.io

26 questions
17
votes
5 answers

How to install Python for .NET on Windows

I downloaded Python for .NET. Inside the zip is clr.pyd, nPython.exe, Python.Runtime.dll and 2 debug database files. I put the clr.pyd and Python.Runtime.dll in my python DLLs dir C:\Python27\DLLs thinking this is all that's needed for installation.…
user441521
  • 6,942
  • 23
  • 88
  • 160
10
votes
1 answer

Implement a C# Interface in Python for .NET

I have been given a library written in C# that I'm trying to call using Python for .NET. The primary class I need an instance of has a constructor like: GDhuClient(IGDhuSettings) There are no (exposed) classes that implement the IGDhuSettings…
Ghillie Dhu
  • 213
  • 2
  • 10
7
votes
4 answers

Import of DLL with pythonnet

I am trying to import and use a DLL in python. Therefore I am using pythonnet. import sys import clr sys.path.append('C:\PathToDllFolder') clr.AddReference('MyDll.dll') However the code yields the following error: Traceback (most recent call…
MJA
  • 357
  • 2
  • 5
  • 10
7
votes
1 answer

Python for .NET: How to explicitly create instances of C# classes using different versions of the same DLL?

I have a .cs file like namespace SomeNamepace { public struct SomeStruct { .... } public static class SomeClass { .... } So far I use it with PythonNET like import…
Joe
  • 6,758
  • 2
  • 26
  • 47
7
votes
1 answer

Calling C# code within Python3.6

with absolutely no knowledge of coding in C#, I wish to call a C# function within my python code. I know there's quite a lot of Q&As around the same problem, but for some strange reason, i'm unable to import a simple c# class library from a sample…
Skanda Avadhani
  • 153
  • 1
  • 7
4
votes
1 answer

How can I get readthedocs.org build to ignore my requirement.txt?

I have a small app project on github which runs on Windows and requires pythonnet. My requirement.txt contains: beautifulsoup4==4.6 pythonnet==2.3 Now I thought I would build a documentation for it and put it on readthedocs.org. After pushing my…
Jacques Gaudin
  • 15,779
  • 10
  • 54
  • 75
3
votes
1 answer

Python for .NET: How to call a method of a static class using Reflection?

I want to use a method of a static class. This is my C# code: namespace SomeNamepace { public struct SomeStruct { .... } public static class SomeClass { public static double SomeMethod { .... …
Joe
  • 6,758
  • 2
  • 26
  • 47
3
votes
2 answers

Pythonnet System.Object[,] to Pandas DataFrame or Numpy Array

I am using Pythonnet to call a C# function which returns a clr Object ( an n x m matrix). In python the type is System.Object[,]. How can I convert this variable to a Pandas DataFrame or something more manageable? Thank you.
cabo
  • 127
  • 1
  • 9
3
votes
2 answers

How to call a C# library function with ref and out parameter from python?

I use pythonnet not ironpython. There is a function like this: test(ref string p1,out string p2) How can I call test in python 3.6? import clr import sys import System sys.path.append(r'd:\dll') clr.FindAssembly('communication.dll') from …
layty
  • 31
  • 6
3
votes
0 answers

Integration of Python code into a C# application when python code contains numpy

I am currently developing an app which is primarily based in .NET but need to integrate some math based code which is in Python3 and contains many references to the numpy, scipy and pandas packages. I have read that IronPython will not support…
anna
  • 51
  • 3
3
votes
0 answers

Anaconda installing pythonnet

Can someone help me with the error I'm getting when I try to install pythonnet in Anaconda. On the website it is stated that I just need to enterconda install -c pythonnet pythonnet or through pip pip install -i…
3
votes
0 answers

Passing and retrieving objects using pythonnet

How do , In general pass and return objects using pythonnet. For example, this works fine if I'm to return a number: dynamic par = Python.Runtime.Py.Import("mypackage.pythonfile"); var t = par.GetPPMError(100, 100.001); where I import a package…
im281
  • 455
  • 1
  • 5
  • 14
2
votes
2 answers

How to enable Intellisense of my own .Net library for a Python application in Visual Studio 2017?

I am using pythonnet ( https://github.com/pythonnet/pythonnet ) and have referenced a .Net library within the same solution space but it does not seem to pull in any information to use for Intellisense. In fact, VS gives an error: "Unable to resolve…
N_tro_P
  • 673
  • 5
  • 15
2
votes
0 answers

How to implement __repr__ for a C# class to be used in python.net?

I have pythonnet v 2.3.0 installed. I have a C# class library which I use in Python. I have a Point class (a code snippet): public Point(double x, double y) { this.x = x; this.y = y; } public override string ToString() { return…
Alex Tereshenkov
  • 3,340
  • 8
  • 36
  • 61
2
votes
2 answers

Python for .NET: How to provide a variable of special type (FTDI.FT_DEVICE_INFO_NODE[]) as method parameter

I want to use a DLL with the help of Python for .NET (pythonnet). The methods in this DLL require (pointer to?) variables as parameters. I could figure out how to call a method and to provide an integer variable as parameter. I could not figure out…
mdk
  • 398
  • 2
  • 8
1
2