ironpython

using functools with IronPython

为君一笑 提交于 2019-12-04 04:47:54
问题 I'm using the functools library with IronPython. It works fine on the development machine, but in production the library can't be imported. Exception is thrown: IronPython.Runtime.Exceptions.ImportException: No module named _functools IronPython is installed on the production machine of course and functools.py is there, but how should I deploy _functools? 回答1: Normally _functools is the native component that functools.py wraps. Given that native modules are not supported in IronPython (as of

Reading UTF-8 file with codecs in IronPython

孤街浪徒 提交于 2019-12-04 03:19:26
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\1.1\visualstudio_py_repl.py", line 492, in run_file_as_main code.Execute(self.exec_mod) File "<string>

How do I pass arguments to a Python script with IronPython

断了今生、忘了曾经 提交于 2019-12-04 03:16:43
问题 I have the following C# code where I call a python script from C#: using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Windows.Forms; using System.Linq; using System.Text; using System.Threading.Tasks; using IronPython.Hosting; using Microsoft.Scripting.Hosting; using IronPython.Runtime; namespace RunPython { class Program { static void Main(string[] args) { ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(null); ScriptRuntime runtime =

Visual Studio - “The environment IronPython|2.7-32 appears to be incorrectly configured or missing”

随声附和 提交于 2019-12-04 03:14:44
问题 Steps to the Reproduce: Open Visual Studio 2017 (Pro on Windows 10 64-bit) File > New Project > IronPython Application Run the default program: print('Hello world') When I run it, I get the following error: The environment "IronPython|2.7-32" appears to be incorrectly configured or missing. You may need to install it or create a virtual environment I went to VS Installer, Individual Components tab, Compilers section, and checked on the Python 2.7 & 3.6 selections, but I'm still getting the

Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host?

爷,独闯天下 提交于 2019-12-04 02:41:22
Would you recommend Iron Ruby, Iron Python, or PowerShell for making a C# application a script host? After some quick tinkering, right now I'm leaning towards powershell for two main reasons (note these a purely my opinions and if they are wrong, I'd love to know!!!): 1) It's simple to create a runspace with classes in your application; therefor it's easy to make your application scriptable. 2) I've heard some rumors that IronRuby and IronPython are losing support from Microsoft, so they may be a poor long term solution? As this is my first time adding scripting to an application though, I'd

How do I convert from a .NET DateTime to an IronPython datetime?

佐手、 提交于 2019-12-03 23:11:06
I'm calling an IronPython script and passing it a .NET object that contains a DateTime structure. I'm trying to use IronPython's JSON support to serialize the object as JSON. Everything works great until I encounter the .NET DateTime . How do I convert from the .NET DateTime to the IronPython datetime ? Anticipating that people might like to convert between these we actually make it really easy: import datetime from System import DateTime datetime.datetime(DateTime.Now) Artsiom Rudzenka As we know, the datetime type has the following structure: datetime(year, month, day[, hour[, minute[,

Iron Python : what are good uses for Iron Python [closed]

大兔子大兔子 提交于 2019-12-03 15:46:36
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I have an affinity for python, but I work in a .NET environment, so I was looking into Iron Python, and wondering what it would be used for. Could you write an app in it? or is it for adding a scripting language to your app? How do you guys use it? 回答1: Either or both :) I wouldn

IronPython w/ C# - How to Read Values of Python Variables

最后都变了- 提交于 2019-12-03 15:15:13
I have two python files: mainfile.py and subfile.py mainfile.py relies on some types in subfile.py. mainfile.py looks something like this. from subfile import * my_variable = [1,2,3,4,5] def do_something_with_subfile #Do something with things in the subfile. #Return something. I'm attempting to load mainfile.py up in C# and get the value of my_varaible, but I'm having some difficulty finding resources that adequately describe the relationships between the methods I'm calling and I, admittedly, don't know a ton about Python. Here's what I have written: var engine = Python.CreateEngine(); //Set

Speed of code execution: IronPython vs C#?

↘锁芯ラ 提交于 2019-12-03 14:38:45
Am trying to provide a response from a Managers perspective to the question: What overall performance penalty will we incur if we write the application in IronPython instead of C#? This question is directed at those who might have already undertaken some testing, benchmarking or have completed a migration from C# to IronPython, in order to quantify the penalty. I created a C# console application (I'm not very good at C#), which basically encrypts an input file using a xor cipher. Code below: using System; using System.IO; using System.Text; using System.Diagnostics; namespace XorCryptor {

BeautifulSoup and ASP.NET/C#

回眸只為那壹抹淺笑 提交于 2019-12-03 12:29:40
问题 Has anyone integrated BeautifulSoup with ASP.NET/C# (possibly using IronPython or otherwise)? Is there a BeautifulSoup alternative or a port that works nicely with ASP.NET/C# The intent of planning to use the library is to extract readable text from any random URL. Thanks 回答1: Html Agility Pack is a similar project, but for C# and .NET EDIT: To extract all readable text: document.DocumentNode.InnerText Note that this will return the text content of <script> tags. To fix that, you can remove