python.net

Using python files with libraries in Visual Studio

杀马特。学长 韩版系。学妹 提交于 2020-01-03 00:53:08
问题 I want to use some python files in a Visual Studio WPF application, using this code. var ipy = Python.CreateRuntime(); dynamic test = ipy.UseFile("Test.py"); string whatever = test.pythonString() MessageBox.Show(whatever); where Test.py looks like this: def pythonString: return "Whatever" everything works as expected but if I add any import like from moviepy.editor import * to the python code the messagebox doesn't appear. Why does this happen and what do I have to change in order to make

Error Installing Python.net on Python 3.7

和自甴很熟 提交于 2020-01-02 10:05:54
问题 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

Use .Net (C#) dll in Python script

 ̄綄美尐妖づ 提交于 2020-01-02 04:35:08
问题 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

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

≡放荡痞女 提交于 2020-01-01 19:46:05
问题 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;_

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

£可爱£侵袭症+ 提交于 2019-12-29 07:52:43
问题 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.Proj.MyRepo: OutputObject GetData(string user, int anID, int? anOptionalID= null) I can call the method for the case where the optional third argument is present but can't figure out what to pass for the third argument to match the null case. import clr clr.AddReference("Our.Namespace.Proj") import

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

倖福魔咒の 提交于 2019-12-29 07:52:10
问题 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.Proj.MyRepo: OutputObject GetData(string user, int anID, int? anOptionalID= null) I can call the method for the case where the optional third argument is present but can't figure out what to pass for the third argument to match the null case. import clr clr.AddReference("Our.Namespace.Proj") import

pypy import clr fails on Windows

落花浮王杯 提交于 2019-12-23 06:47:39
问题 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 MSC v.1500 32 bit] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>> import clr Attempting to load 'Python.Runtime' using standard binding rules. 'Python.Runtime' not found using standard binding rules. Attempting

IronPython vs Python speed with numpy

◇◆丶佛笑我妖孽 提交于 2019-12-23 01:05:08
问题 I have some Python source code that manipulates lists of lists of numbers (say about 10,000 floating point numbers) and does various calculations on these numbers, including a lot of numpy.linalg.norm for example. Run time had not been an issue until we recently started using this code from a C# UI (running this Python code from C# via IronPython). I extracted a set of function calls (doing things as described in the 1st paragraph) and found that this code takes about 4x longer to run in

How can I open a .NET FileStream object from a Python file handle?

烂漫一生 提交于 2019-12-22 12:36:10
问题 I need to open a writable file handle in Python and then hand off the file descriptor to a function in a .NET assembly (accessed via pythonnet's clr module. Getting from the Python file object to the win32 HANDLE* is fairly straightforward, as shown in this question: import clr from Microsoft.Win32.SafeHandles import SafeFileHandle from System.IO import FileStream, FileAccess pyf=open("c:/temp/testing123.txt","w") fileno=pyf.fileno() print fileno # 6 handle = msvcrt.get_osfhandle(fileno)

pythonnet Embedding Python in .net example failing to load module

跟風遠走 提交于 2019-12-22 11:31:17
问题 I'm trying to run the Embedding Python in .NET example from https://github.com/pythonnet/pythonnet. I've followed troubleshooting articles to set the proper %PYTHONPATH% and %PYTHONHOME% to my anaconda environment in the program base directory. After activating my anaconda environment, I have successfully imported sys, and imp as a test, and also sucessfully used PythonEngine.RunSimpleString(), but the numpy example fails with Python.Runtime.PythonException: ImportError : No module named