python.net

How can I get generics to work in Python.NET with CPython

做~自己de王妃 提交于 2019-12-06 08:51:54
How can I get generics to work in Python.NET with CPython. I get an error when using the subscript syntax from Python.NET Using Generics TypeError: unsubscriptable object With Python 2.7.11 + pythonnet==2.1.0.dev1 >python.exe Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import clr >>> from System import EventHandler >>> from System import EventArgs >>> EventHandler[EventArgs] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError:

Error Installing Python.net on Python 3.7

旧巷老猫 提交于 2019-12-06 07:41:33
I am attempting to get Python.net (pythonnet) working on Python 3.7 and when running the setup.py it fails with the following error. I'm assuming that it has to do with a missing entry in the path lines but I coulnd't fine any reference to it. It's basically a pretty plain install of Python 3.7 on Windows 7. the pip install also fails with the same results. Does anyone have a suggestion on what path or file might be missing? PS C:\Users\user\pythonnet-master\pythonnet-master> python setup.py bdist_wheel running bdist_wheel running build running build_ext Checking for updates from https://www

Python for .Net Error: ImportError: No module named

别来无恙 提交于 2019-12-06 07:32:05
We are using Python for .Net to call .NET API built using C# from Python script. We are getting ImportError: No module named - error when an import is done as follows. Python script: import sys sys.path.append(r"C:\myfolderA\myfolderB") print sys.path import clr clr.FindAssembly(r"AA.BB.CC") clr.AddReference(r"AA.BB.CC") from AA.BB.CC.Api.DDInterface import DDClient On the above line I am getting following error Traceback (most recent call last): File "C:\myfolderA\myfolderB\testAPI.py", line 7, in <module> from AA.BB.CC.Api.DDInterface import DDClient ImportError: No module named AA.BB.CC.Api

Python .net framework reference argument Double[]&

风流意气都作罢 提交于 2019-12-06 04:45:48
问题 Using the Python for .Net framework I'm trying to call a method from a C# .dll file. This method has the following arguments: public static void ExternalFunction( String Arg1, ref Double[]& Arg2, ); I understood the .Net framework converts Python floats to doubles. Now I would like to know how to make an array (double) and pass this as a reference to the external method. I've the following code: import clr clr.AddReference("MyDll") from MyLib import MyClass myName = "Benjamin" r = MyClass

Use .Net (C#) dll in Python script

孤人 提交于 2019-12-05 10:53:55
I'm attempting to port a simple C# command-line utility to Python. The C# program uses a custom .Net dll called foobar.dll that interfaces with some lab equipment via I2C. The usage of the dll in the C# code is as follows: fooBar.fooProvider provider = new foobar.fooProvider() fooBar.fooBarLib fooLib = new foobar.fooBarLib(provider, 0x80) # used below ... numFloat = fooLib.GetSomething() # more python ... fooLib.SetSomething(NumberAsAFloat) I thought about simply using ctypes to access the dll, but I figured this wouldn't work for C#/.Net. Due to restrictions in our lab I need to use a vanilla

How to unload a .NET assembly reference in IronPython

老子叫甜甜 提交于 2019-12-05 06:09:50
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? Because I'm recompiling foo.dll and want to reload it, but the compiler is giving me a fuss, since IronPython is allready accessing foo.dll . .NET itself doesn't support unloading just a single assembly. Instead, you need to unload a whole AppDomain . I don't know exactly how IronPython works with AppDomain s, but that's the normal .NET way of doing things. (Load the assembly into a new AppDomain , use

Python and .NET integration

隐身守侯 提交于 2019-12-04 21:38:19
问题 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 for me because I am using NLTK and presumably would need a port of that library to the CLR. I've looked a little at Python for .NET and was wondering if this was a good place to start. Is there a way to marshal a python class into C#? Also, is this solution still being used? Better yet, has

Install pythonnet on Ubuntu 18.04, Python 3.6.7 64-bit, Mono 5.16 fails

柔情痞子 提交于 2019-12-04 20:28:18
I would like to install pythonnet on Ubuntu, but it fails. That's what I tried so far: /usr/bin/python3 -m pip install -U pythonnet --user Error: Collection pythonnet Using cached https://files.pythonhosted.org/packages/89/3b/a22cd45b591d6cf490ee8b24d52b9db1f30b4b478b64a9b231c53474731e/pythonnet-2.3.0.tar.gz Building wheels for collected packages: pythonnet Running setup.py bdist_wheel for pythonnet ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-sv3ax85u/pythonnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f

Can we load pandas DataFrame in .NET ironpython?

荒凉一梦 提交于 2019-12-04 20:09:45
问题 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. 回答1: No, Pandas is pretty well tied to CPython. Like you said, your best bet is to do the analysis in CPython with Pandas and export the result to CSV. 回答2: Regarding the option including serialization: I'm still investigating similar case - we want to process the data in python and then use the results in c#. Our requirement was to

Python NET call C# method which has a return value and an out parameter

随声附和 提交于 2019-12-04 19:14:25
I'm having the following static C# method public static bool TryParse (string s, out double result) which I would like to call from Python using the Python NET package. import clr from System import Double r0 = Double.IsNaN(12.3) # works r1, d1 = Double.TryParse("12.3") # fails! TypeError: No method matches given arguments. This works in IronPython. d2 = 0.0 r2, d2 = Double.TryParse("12.3", d2) # fails! TypeError: No method matches given arguments Any idea? Update I found the following answer, see https://stackoverflow.com/a/19600349/7556646 . CPython using PythonNet does basically the same