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
0
votes
1 answer

Python.Net C# using thread to call python function

I am currently working with C# and Python through PythonNet. It works well calling and using python functions from C#. However, the problem is when I tried to call python function in async condition by using multi-thread. As I googled so far, I…
hanbi Kim
  • 1
  • 1
0
votes
0 answers

running .dll from Python yields error: please enable loadFromRemoteSources switch

I have installed the pythonnet package using pip install pythonnet for the purposes of capturing the output from a .dll file I have been provided. The .dll makes an API call. To run the .dll through python, I have this code: import…
FreyGeospatial
  • 325
  • 4
  • 17
0
votes
0 answers

Pythonnet in C# - debugger stopped when PythonEngine.Initialize() is called

I tried to run Python code from c# using pythonnet. I followed this intstuction: https://somegenericdev.medium.com/calling-python-from-c-an-introduction-to-pythonnet-c3d45f7d5232 but debugger stopped when I run the line PythonEngine.Initialize().…
Jason
  • 313
  • 2
  • 8
0
votes
0 answers

IronPython, Python .NET (or anything else) to edit an xml table inside Excel? Openpyxl seems to corrupt the file

I have to do something really simple, and so complicated at the same time. I have two files, one with data. like this: file1 And the other one is a template, with an xml table headings on A3 and the first row has to be the same always, like…
0
votes
2 answers

Object initialization in Pythonnet

Let's assume I've the following C# class: public class Test { public double X; public double Y; } I want to use the above C# Test class from IronPython and as well from CPython (using Pythonnet). Using IronPython 2.7 I was able to generate…
Wollmich
  • 1,616
  • 1
  • 18
  • 46
0
votes
0 answers

Converting PyObject to C# Object

I have a dictionary in python that I am passing to C# code using python.net (Python.Runtime.Allplatforms(3.7.2.4) dictionary in python: {"Str12":"okay"} C# Code: var qwe = new Dictionary(); using (PyScope scope =…
qwerty
  • 887
  • 11
  • 33
0
votes
1 answer

Pythonnet cann't load System.IO.Path (.net 6.0)

I use Python 3.10 and Net 6.0. And my C# code call Directory.GetFiles function from System.IO. When I call dll from python using Pythonnet, it showed cannot load type: System.IO.Path. Please provide some instructions. Thanks.
0
votes
0 answers

Python.Runtime.PythonException - when running custom python script in .NET environment using python.NET

Apparently, python interpreter is unable to find location of the hello_world.py script which I'm trying to run by using python.NET. I think I've set the environment variables correctly. Even though I've added the MyScripts path to the PYTHONPATH…
0
votes
0 answers

Label fails to render using python.net

I'm trying to rebuild a C# .net form I built in visual studio in Python to better suit my needs. After some googling around, I came across the package python.net/pythonnet and it's exactly what I've been looking for. Unfortunately, for some reason,…
0
votes
0 answers

how to set runtime in python?

this is the error Severity Code Description Project File Line Suppression State Error CS0234 The type or namespace name 'Runtime' does not exist in the namespace 'Python' (are you missing an assembly reference?) …
ur mom
  • 17
  • 5
0
votes
1 answer

Python.Runtime.dll not found in Azure Function(v4)

we have created an Azure function in the dotnet framework(.NET6) that processes some python scripts in runtime using pythonnnet which was embedded inside Numpy(3.7.1.28) - Nuget package. Locally everything works fine(VS 2022, Windows 10). But once…
0
votes
1 answer

System.DllNotFoundExecption Error - PythonNet C# and Python3.8

I am interested to call my existing python 3.8 modules from an developed WPF Application(Net Core3.1). I did the following: I installed pythonnet with: pip install pythonnet Set environment paths in C# (in VS2019) : string pyInstallDir =…
Daniel
  • 1
  • 1
0
votes
0 answers

Pythonnet implement interface with generic method

In pythonnet, I'm trying to implement an interface with a generic method. To be more precise, I'm trying to implement an custom decoder in python, so I would like to implement IPyObjectDecoder, which has a generic TryDecode method. Here is my…
0
votes
0 answers

Embedding Python in a C# project with pythonnet (not working)

I am embedding python script in a C# project for my work. I found several very detailed articles to give me instruction to setup the pythonnet environment. I tested a very simple sample code from those instruction. However, I tried many times and…
david3000
  • 11
  • 1
0
votes
0 answers

Call a C# method with DTO as entered parameter in python

I am using pythonnet and import .Net dll without any problem, but I faced with new problem when I want to call a C# method with DTO as entered parameter not primitive type such as string,int,bool and etc. For Example (C# .Net), Suppose we have this…