Questions tagged [python.net]

Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and Mono. Pythonnet provides a powerful application scripting tool for .NET developers. Using this package you can script .NET applications or build entire applications in Python, using .NET services and components written in any language that targets the CLR (C#, VB.NET, F#, C++/CLI) and CPython.

Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and Mono. Pythonnet provides a powerful application scripting tool for .NET developers. Using this package you can script .NET applications or build entire applications in Python, using .NET services and components written in any language that targets the CLR (C#, VB.NET, F#, C++/CLI) and CPython.

https://pythonnet.github.io/

578 questions
197
votes
9 answers

How do I run a Python script from C#?

This sort of question has been asked before in varying degrees, but I feel it has not been answered in a concise way and so I ask it again. I want to run a script in Python. Let's say it's this: if __name__ == '__main__': with open(sys.argv[1],…
Inbar Rose
  • 41,843
  • 24
  • 85
  • 131
93
votes
10 answers

IronPython vs. Python .NET

I want to access some .NET assemblies written in C# from Python code. A little research showed I have two choices: IronPython with .NET interface capability/support built-in Python with the Python .NET package What are the trade-offs between both…
cschol
  • 12,799
  • 11
  • 66
  • 80
59
votes
5 answers

Calling a C# library from python

Anyone can share a working example on how to call a simple C# library (actually its WPF) from python code? (I have tried using IronPython and had too much trouble with unsupported CPython library my python code is using so I thought of trying the…
ychuri
  • 661
  • 1
  • 8
  • 9
37
votes
5 answers

How to load a C# dll in python?

how can I load a c# dll in python? Do I have to put some extra code in the c# files? (like export in c++ files) I don't want to use IronPython. I want to import a module to Python!
aF.
  • 64,980
  • 43
  • 135
  • 198
34
votes
1 answer

pypy import clr fails on Windows

I tried pythonnet with pypy on Win10. It builds fine, but then fails to import clr. The crash happens after this call in the screenshot. Any tips/tools for debugging this? pypy Python 2.7.12 (aff251e54385, Nov 09 2016, 17:54:55) [PyPy 5.6.0 with…
denfromufa
  • 5,610
  • 13
  • 81
  • 138
23
votes
4 answers

Python: AttributeError: 'module' object has no attribute 'AddReference'?

Am trying to use clr.AddReference and clr.AddReferenceToFile to import an assembly, but python(2.7) keeps making this error: Traceback (most recent call last): File "", line 1, in
Ran
  • 635
  • 2
  • 10
  • 22
23
votes
2 answers

How to install NumPy for IronPython in 2017?

I have found the old answer to this question, but the instructions provided in the mentioned post are no longer working... Essentially the URL where NumPy for IronPython was stored is broken. How to install NumPy for IronPython in 2015/2016
Krystian Sakowski
  • 1,613
  • 14
  • 20
23
votes
3 answers

Integration of python in C# Application

I have the following problem: I got an old application which is written in python. This application allows the user to specify small python steps which will be executed, python steps are basically small python scripts, I call them steps because the…
Xeun
  • 1,089
  • 1
  • 11
  • 20
21
votes
2 answers

How to inherit from an abstract base class written in C#

I’m trying to inherit from an abstract .NET base class in Python (2.7) using Python.NET (2.1.0). I’m a Python n00b but from what I understood… Here’s what I managed to do in Python only and which works fine: import abc class Door(object): …
freefall
  • 388
  • 1
  • 14
21
votes
7 answers

Python for .NET "unable to find assembly" error

I'm using CPython and I have a C# dll. I'm trying to use Python for .NET to make them talk. I can't use IronPython because I need to integrate this into an existing CPython system. I'm completely new to Python for .NET, and I actually have very…
Annie
  • 335
  • 1
  • 2
  • 6
18
votes
6 answers

Call Python from .NET

I have some code written in Python which can not be transferred to a .NET language. I need to call one of these functions from my .NET WinForms application. Now, I do it by starting the Python script as a separate process and pass parameters to it…
Tom
  • 3,899
  • 22
  • 78
  • 137
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
16
votes
2 answers

Has anyone used SciPy with IronPython?

I've been able to use the standard Python modules from IronPython, but I haven't gotten SciPy to work yet. Has anyone been able to use SciPy from IronPython? What did you have to do to make it work? Update: See Numerical computing in IronPython…
John D. Cook
  • 29,517
  • 10
  • 67
  • 94
15
votes
1 answer

How to install packages/modules in IronPython

I am new to IronPython. Thanks for you help and patience. I installed IronPython 2.7 from http://ironpython.net/ in Visual Studio 2015. I also installed Python 2.7.6 and anaconda. I tried the following solution and it didn't work. Installing Python…
Hikaru
  • 151
  • 1
  • 1
  • 3
15
votes
4 answers

How to export C# methods?

How can we export C# methods? I have a dll and I want to use its methods in the Python language with the ctypes module. Because I need to use the ctypes module, I need to export the C# methods for them to be visible in Python. So, how can I export…
aF.
  • 64,980
  • 43
  • 135
  • 198
1
2 3
38 39