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.

Filter by
Sorted by
Tagged with
131
votes
8answers
251k views

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 ...
84
votes
10answers
65k views

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 ....
44
votes
4answers
71k views

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 ...
34
votes
1answer
2k views

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 (...
25
votes
4answers
61k views

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!
19
votes
2answers
1k views

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 ...
18
votes
6answers
17k views

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 ...
17
votes
6answers
25k views

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 ...
16
votes
5answers
32k views

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 ...
16
votes
2answers
4k views

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? ...
15
votes
5answers
4k views

Python - IronPython dilemma

I'm starting to study Python, and for now I like it very much. But, if you could just answer a few questions for me, which have been troubling me, and I can't find any definite answers to them: What ...
15
votes
4answers
7k views

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 ...
14
votes
3answers
37k views

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 ...
14
votes
2answers
8k views

IronPython invocation from C# (with SciPy) fails with ImportException: “No module named mtrand”

I have a python library I am trying to use via IronPython (v2.7 RC1 [2.7.0.30]) invocation from C# application. The library uses NumPy and SciPy quite extensively, which does work with SciPy and NumPy ...
13
votes
6answers
5k views

Creating an interactive shell for .NET apps and embed scripting languages like python/iron python into it

I was learning python using the tutorial that comes with the standard python installation. One of the benefits that the author states about python is "maybe you’ve written a program that could use an ...
13
votes
1answer
1k views

How to do multiprocessing using Python for .NET on Windows?

Now I'm developing C# app running on Windows. Some of processes are written in Python, that called via pythonnet (Python for .NET). The processes are calculation-heavy, so I want to do them in ...
12
votes
6answers
1k views

Can I treat IronPython as a Pythonic replacement to C#?

I do understand that this topic has been covered in some way at StackOverflow but I'm still not able to figure out the exact answer: can I treat IronPython as a Pythonic replacement to C#? I use ...
12
votes
1answer
690 views

Why does Python.NET use the base method instead of the method from a derived class?

Edit: This will be fixed in a new version of pythonnet (when this pull request is merged). I have a problem with Python.NET inheritance. I have a DLL which consists of the following code: using ...
12
votes
1answer
11k views

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 ...
12
votes
1answer
617 views

How to save plots from multiple python scripts using an interactive C# process command?

I've been trying to save plots(multiple) from different scripts using an interactive C# process command. Objective: My aim is to save plots by executing multiple scripts in a single interactive ...
11
votes
2answers
10k views

How to integrate Python Code with C#.Net Core language? [closed]

Am trying to integrate python code in my .net core application for data analysis and some machine learning classification. How can I do this the best way? Note: I don't want to execute scripts with ...
11
votes
0answers
2k views

How to install NumPy for IronPython in 2017?

I have found old answer to this question but instruction provided in the mentioned post is no longer working... Essentially the URL where NumPy for IronPython was stored is broken. How to install ...
10
votes
3answers
3k views

Compile Brotli into a DLL .NET can reference

So I'd like to take advantage of Brotli but I am not familiar with Python and C++.. I know someone had compiled it into a Windows .exe. But how do I wrap it into a DLL or something that a .NET app ...
10
votes
3answers
8k views

Can we load pandas DataFrame in .NET ironpython?

Can we load a pandas DataFrame in .NET space using iron python? If not I am thinking of converting pandas df into a csv file and then reading in .net space.
9
votes
2answers
11k views

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 "<pyshell#5>", line 1, in ...
9
votes
2answers
11k views

Using C# Assemblies from Python via pythonnet

I am using Windows 7, 64-bit. I have managed to download and install pythonnet, so import clr clr.AddReference("System.Windows.Forms") from System.Windows.Forms import Form works fine. I have also ...
8
votes
2answers
7k views

PythonNet FileNotFoundException: Unable to find assembly

I am trying to execute a Python script that uses Python For .Net (https://github.com/pythonnet/pythonnet) to load a C# library called "Kratos_3.dll" which is in the same folder as the script but the ...
8
votes
3answers
6k views

Python and .NET integration

I'm currently looking at python because I really like the text parsing capabilities and the nltk library, but traditionally I am a .Net/C# programmer. I don't think IronPython is an integration point ...
8
votes
3answers
3k views

Python for .NET: ImportError: No module named warnings

I am trying to embed python 2.6 in .NET 4.0. Following the very minimal documentation in "Python for .NET", I wrote a fairly straightforward code as follows: const string pythonModulePath = @"C:\...
7
votes
5answers
864 views

Running Python Code in .NET Environment without Installing Python

Is it possible to productionize Python code in a .NET/C# environment without installing Python and without converting the Python code to C#, i.e. just deploy the code as is? I know installing the ...
7
votes
3answers
5k views

Calling python code(.py files) from C#

I have some python code that does a certain task. I need to call this code from C# without converting the python file as an .exe, since the whole application is built on C#. How can I do this?
7
votes
2answers
1k views

Python property factory or descriptor class for wrapping an external library

I am writing a Python wrapper class for a C# API accessed through Pythonnet. As I want to extend the API with my own methods I decided to wrap it using the composition approach outlined here: The C# ...
7
votes
1answer
5k views

how to access a class from a dll in python?

I have a handfull of .dll files with classes designed to control an external device connected to my desktop via ethernet. I'd like to import these classes to python and use their member functions / ...
6
votes
3answers
13k views

ImportError: No module named clr when using CPython of python.org

I'm writing C++ code which should invoke python scripts underneath. For this purpose I use cpython of python.org. Some of the python scripts execute .net code with help of python for .net and when it ...
6
votes
2answers
4k views

The definitive method to use NumPy and SciPy from IronPython

There is a way to use NumPy/SciPy in IronPython, using IronClad to execute/communicate with the CPython binaries of the same. A newer project, Python Tools for VS allows for a faster integration with ....
6
votes
1answer
2k views

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 (...
6
votes
1answer
12k views

Use .NET dll in Python [duplicate]

I've developed a dll in visual studio that I'd now like to use in Python using the standard IDLE. I cannot seem to find a straightforward solution to this anywhere. I've tried using pip install *dll ...
6
votes
3answers
2k views

Creating a C# Nullable Int32 within Python (using Python.NET) to call a C# method with an optional int argument

I'm using Python.NET to load a C# Assembly to call C# code from Python. This works pretty cleanly, however I am having an issue calling a method that looks like this: A method within Our.Namespace....
6
votes
1answer
2k views

Would you share your idea how to call python command from embedded Python.Net?

I've been played with Python.Net for a week, but I can't find any sample code to use Python.Net in embedded way although Python.Net source has several embeddeding tests. I've searched many threads ...
6
votes
1answer
1k views

How to unload a .NET assembly reference in IronPython

After loading a reference to an assembly with something like: import clr clr.AddRferenceToFileAndPath(r'C:\foo.dll') How can I unload the assembly again? Why would anyone ever want to do this? ...
6
votes
1answer
2k views

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 ...
6
votes
2answers
917 views

Python tkinter.filedialog askfolder interfering with clr

I'm mainly working in Spyder, building scripts that required a pop-up folder or file Browse window. The code below works perfect in spyder. In Pycharm, the askopenfilename working well, while ...
6
votes
1answer
315 views

for scriptcs `dynamic` is not supported by Roslyn and available only with mono, but mono fails on DLL

I'm try to load pythonnet runtime dll from scriptcs and it does not work with roslyn backend because dynamic is not supported in Roslyn, but mono backend chokes with the following error: $ scriptcs -...
6
votes
2answers
1k views

Accessing webcam via DirectShow using COM with Python

I want to get low level access to webcam properties using DirectShow's IAMVideoProcAmp. There are several Python modules )pywin32, pywintypes, comtypes, win32com, pythoncom) that are used in this ...
6
votes
2answers
2k views

Python for .NET

I have a problem loading an external dll using Python through Python for .NET. I have tried different methodologis following stackoverflow and similar. I will try to summarize the situation and to ...
6
votes
1answer
2k views

Using System.Collections.Generic.List`1[System.Byte] in Python

I have a Python script which receives data from a .NET application. How do I use an incoming buffer of type 'System.Collections.Generic.List`1[System.Byte]' in my script? The function of the script ...
6
votes
0answers
2k views

Calling .NET library function from Python

I am almost at the end of my wits here and am hoping you all could help me figure this one out. I am running Anaconda Python 3.5 64 bit and compiled Python.NET anaconda package to add .NET ...

1
2 3 4 5
8