ironpython

How namespace and assembly names work for IronPython types?

不问归期 提交于 2019-12-06 01:21:22
Have an IronPython package named "Entities". That package contains an "Entity.py" file that defines a "Customer" class and an "Address" class. If I run this program: customer = Customer() print customer.GetType().AssemblyQualifiedName address = Address() print address.GetType().AssemblyQualifiedName I get this output: IronPython.NewTypes.System.Object_1$1, Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null IronPython.NewTypes.System.Object_1$1, Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null How does that work? Why do both types have the same

Pass a C# Class Object to a Python file

核能气质少年 提交于 2019-12-05 23:33:27
Okay... I'm trying to pass an Object which I declare in C# to a Python file with IronPython. So this is what I was thinking off: C# class: public class ParamObj { private string Obj_String; private int Obj_Int; public ParamObj(string lObjS, string lObjI) { Obj_String = lObjS; Obj_Int = lObjI; } public string getString() { return Obj_String; } public int getInt() { return Obj_Int; } public setString(string lStr) { Obj_String = lStr; } public setInt(int lInt) { Obj_Int = lInt; } } So i have my Class.. Now i declare the Class in my C# Project and i pass it to the PYthon file: ParamObj Test_Object

Using `dynamic` keyword in C# doesn't compile

隐身守侯 提交于 2019-12-05 23:00:27
I'm trying to compile a piece of C# code that contains the dynamic keyword. (I need this keyword for using ironpython.) However, it doesn't compile, complaining that error CS1980: Dynamic keyword requires `System.Runtime.CompilerServices.DynamicAttribute' to be defined. Are you missing System.Core.dll assembly reference? The compiler I'm using is Mono JIT compiler version 2.10.8.1 . I don't have System.Runtime.CompilerServices.DynamicAttribute in the list of possible references. How can I make mono accept the dynamic keyword? Chiel ten Brinke This comment of Hans Passant solved the problem:

Distributing IronPython applications

僤鯓⒐⒋嵵緔 提交于 2019-12-05 19:59:57
I'm thinking of developing a small application using IronPython, however I want to distribute my app to non-techies and so ideally I want to be able to give them a standard shortcut to my application along with the instructions that they need to install IronPython first. If possible I even want my shortcut to detect if IronPython is not present and display a suitable warning if this is the case (which I can do using a simple VbScript) The trouble is that IronPython doesn't place itself in the %PATH% environment variable, and so if IronPython is installed to a nonstandard location my shortcut

Reading UTF-8 file with codecs in IronPython

蹲街弑〆低调 提交于 2019-12-05 18:09:09
问题 I have a .csv file encoded in UTF-8, which contains both latin and cyrillic symbols. ;F1;F2;abcdefg3;F200 ;ABSOLUTE;NOMINAL;NOMINAL;NOMINAL o1;1;USA;Новосибирск;1223 I'm trying to execute following script in IronPython 2.7.1: import codecs f = codecs.open(r"file.csv", "rb", "utf-8") f.next() During the execution of f.next() an exception occurs: Traceback (most recent call last): File "c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Microsoft\Python Tools for Visual Studio

Importing mgcv fails because Rlapack.dll cannot be found

限于喜欢 提交于 2019-12-05 14:02:00
I want to link to the R statistical package in IronPython by using the R.NET library. It's been working fine, but now I need to use R's mgcv library. Importing mgcv fails (import is done with the command rdn.r.EagerEvaluate("library(mgcv)") , where rdn is an IronPython object that wraps the R.NET library). When the import fails, Windows opens a dialog box that says: "The program can't start because Rlapack.dll is missing from your computer. Try reinstalling the program to fix this problem." Of course, R never would have worked in the first place if Rlapack.dll was missing, so what is going on?

How to refer self-contained C# class library project with IronPython inside (Visual Studio 2010)

江枫思渺然 提交于 2019-12-05 12:27:13
This question is kind of lengthy but I try to provide you with the details that I think is necessary to find the answer. I have a C# WPF solution (.Net 4) consisting of a main project, building a WPF windows app, which depends on a few class library projects residing in the same Visual Studio 2010 solution. One of the class library projects encapsulates some previously developed python code that I want to make use of through IronPython and Microsoft Dynamic Language Runtime. I would like the class library project to be self contained and not depend on a complete installation of IronPython. The

C# / IronPython Interop and the “float” data type

こ雲淡風輕ζ 提交于 2019-12-05 11:00:20
Working on a project that uses some IronPython scripts to as plug-ins, that utilize functionality coded in C#. In one of my C# classes, I have a property that is of type: Dictionary<int, float> I set the value of that property from the IronPython code, like this: mc = MyClass() mc.ValueDictionary = Dictionary[int, float]({1:0.0, 2:0.012, 3:0.024}) However, when this bit of code is run, it throws the following exception: Microsoft.Scripting.ArgumentTypeException was unhandled by user code Message=expected Dictionary[int, Single], got Dictionary[int, float] To make things weirder, originally the

run Python functions from vb.net

馋奶兔 提交于 2019-12-05 09:53:28
I am new with vb.net. I am trying to call python functions from vb.net but getting error that 'Invoke' is not a member of 'Microsoft.Scripting.Hosting.ObjectOperations' Imports Microsoft.Scripting Imports Microsoft.Scripting.Hosting Imports IronPython.Hosting Sub Main Dim engine As ScriptEngine Dim scope As ScriptScope Dim i As Integer engine = Python.CreateEngine() scope = engine.ExecuteFile("C:\Working.py") Dim v = engine.Operations.Invoke(scope.GetVariable(methodName)) ' name of the method thaT NEEDS TO INVOKED AND GET THE RETURN VALUE. Can anyone please recommend me better way to make this

execute a python script in C#

倖福魔咒の 提交于 2019-12-05 08:23:41
I am trying to execute a python code in C#. Normally it should be done using IronPython and after installing PTVS (I'm using VS 2010). var pyEngine = Python.CreateEngine(); var pyScope = pyEngine.CreateScope(); try { pyEngine.ExecuteFile("plot.py", pyScope); } catch (Exception ex) { Console.WriteLine("There is a problem in your Python code: " + ex.Message); } The problem is that it seems that IronPython doesn't recognize some libraries like numpy, pylab or matplotlib. I took a look a little bit and found some people talking about Enthought Canopy or Anaconda, which i have both installed