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
0 answers

pythonnet (2.5.2) build failures, offline install

VERY new at this, but I've tried almost every site and read almost any documentation I can find. Our tricky situation is trying to create a system that ultimately supports pythonnet(2.5.2) on a CentOS 7 that has no access to the internet. We have…
0
votes
1 answer

Pythonnet TypeError when initializing class

I'm trying to access a class inside a .dll file using pythonnet and I am unable to create and instance of a class without the following error. I'm using the latest version of pythonnet (2.5.2) and Python 3.10.5. Error Traceback (most recent call…
ssmith
  • 1
  • 1
0
votes
0 answers

Win32Exception: Access Denied when trying to embed Python into C# UWP Project

I am trying to run some Python scripts in my UWP project with pythonnet. After setting Runtime.PythonDLL equal to python38.dll path, PythonEngine.Initialize(); throws a 'System.DllNotFoundException'. Specifically, Win32Exception: Access Denied.…
levente.nas
  • 83
  • 2
  • 10
0
votes
1 answer

Python can't find module for import

I have a dll file that I need to import in Python. However when I try to load the assembly I get the error: ModuleNotFoundError: No module named 'TEST_NET' The assembly dll file is located in C:\Program Files\TEST APP\APP 7.0 under the name…
0
votes
1 answer

System.Collections.Generic lists in Python 'TypeError: type(s) expeected' error

I am trying to run the following piece of code: import clr import sys #import System.Collections clr.AddReference("System.Collections") from System.Collections.Generic import List from System import String class MyClass(object): def…
0
votes
1 answer

Installing Pythonnet package on MacOS v12.4

Has anyone installed Pythonnet on Python 3.10.0 (was pre-installed with Mac OS)? When I try to install Pythonnet through PIP, it complains that there is some issue with the package, and not with PIP!! After searching a bit on Google , I found that…
0
votes
1 answer

Cannot run Python script from C# due to missing "encodings" module with Pythonnet

I'm trying to run a Python module from within C# by using an existing (and working) virtualenv. I get ModuleNotFoundError: No module named 'encodings', maybe due to an incorrect loading of the Python DLL. I tried every possible order combo when…
exrezzo
  • 497
  • 1
  • 5
  • 24
0
votes
0 answers

OpenCv error in function Circle. Works on python 3.9 but dont work on python 3.8

Hi i trying to run some python program for image analyse. I got configured environment on python 3.9 and there its works fine with anaconda, but now i need to run it on python 3.8 becouse i have to integrate this Py with Python.NET. After running my…
Daxter44
  • 115
  • 12
0
votes
1 answer

In Pythonnet BeginAllowThreads crashes when calling C# object from Python

Using Pythonnet I'm calling a long-running method on a CLR object from within a Python script. I want to use BeginAllowThreads to allow other threads obtain the GIL as described here: Pythonnet Threading. However the call to BeginAllowThreads…
cjm1905
  • 1
  • 1
0
votes
1 answer

How to make WPF MVVM Bindings work in python.NET (Cpython)?

I'm trying to port this IronPython WPF example to CPython with python.NET. I'm able to get the window running after fixing some known issues (adding __namespace__ to the ViewModel class, using Single Thread Apartment and updating the syntax of…
sanzoghenzo
  • 598
  • 5
  • 21
0
votes
1 answer

TypeLoadException in Python while using Python.Net

I am using 2 .net class libraries in the Python using Python.Net Wanted to pass class object as parameter in a method call PT.cs using System; namespace Point { public class PT { public int x { get; set; } public int y {…
0
votes
1 answer

Pythonnet (clr) and C# lists and enums

I have myClass which contains a field myList which is a list of elements from myEnum. I would like to add to this list more elements but in python. However exec(f"myClass.myList.Add(myEnum.{e}))" doesnt work because myClass.myList in Python is a…
Cugusek
  • 3
  • 1
0
votes
1 answer

convert stored()[:10] function in python to .net syntax (pythonnet)

I have python script and I try to rewrite it using pythonnet in .net. This But i confuse how to convert this line in python to .net? contours = sorted(contours, key = cv2.contourArea, reverse = True)[:10]
nawar
  • 63
  • 10
0
votes
0 answers

TypeError on calling C# .dll API from python using pythonnet

I am trying to call C# APIs from python script, while doing so, I face TypeError, saying the API, that I am trying to call via python doesn't exist. I have verified the .dll to be present in the path, and is of proper format(32 bit).Below are the…
user13252
  • 75
  • 1
  • 7
0
votes
0 answers

Python.NET garbage collection

I try to integrate an external C# Library in a Python project. The library reads and converts some file contents that I want to consume in Python and then delete the file: import clr from pathlib import Path import os import gc my_dll =…
user106745
  • 183
  • 1
  • 8