ironpython

How to use a C# dll in IronPython

蹲街弑〆低调 提交于 2019-11-27 13:39:51
I have created a dll using C#. How do use the dll in IronPython. I have tried to add the dll using clr.AddReference("yxz.dll") . But it fails. I have tried placing the dll in the execution directory of the IronPython script. Still it fails stating that "Name xyz cannot be found" while trying to refer the dll. import clr clr.AddReferenceToFileAndPath(r"C:\Folder\Subfolder\file.dll") is the simplest way as proposed by Jeff in the comments. This also works: import clr import sys sys.path.append(r"C:\Folder\Subfolder") # path of dll clr.AddReference ("Ipytest.dll") # the dll import TestNamspace #

How do I call a specific Method from a Python Script in C#?

旧巷老猫 提交于 2019-11-27 12:11:18
I'm wondering if there is a possibility to call a specific Method from a Python script over a C# project. I have no code... but my idea is: Python Code: def SetHostInfos(Host,IP,Password): Work to do... def CalcAdd(Numb1,Numb2): Work to do... C# Code: SetHostInfos("test","0.0.0.0","PWD") result = CalcAdd(12,13) How can I call one of the Methods, from this Python script, over C#? Simon Opelt You can host IronPython, execute the script and access the functions defined within the script through the created scope. The following sample shows the basic concept and two ways of using the function from

IDE for ironpython on windows

主宰稳场 提交于 2019-11-27 11:34:16
I am currently learning ironpython and loving but i'm looking to move on from using notepad++ and cmd.exe and try using something with a bit more juice. I recently learned that iron python studio does not support iron python 2 so that makes my choice a bit more difficult. Is their any IDE's for windows that would be good iron python 2 development? SharpDevelop with IronPython 2.0 Beta Integration is worth a look - especially given that it's free. Also, check out this Iron Python 2 - what IDE do YOU use? discussion. Seems to confirm your belief that "IronPython Studio doesn't support IronPython

What is a safe way to stop a running thread?

半腔热情 提交于 2019-11-27 09:06:14
I have a thread which contains execution of an IronPython script. For some reason I may need to stop this thread at any time, including script execution. How to achieve this? The first idea is Thread.Abort() , but it's known to be evil... Tudor Well from you question and subsequent comments I can suggest you two options, with some additional "warnings": If your thread loops executing something on each iteration, you can set a volatile boolean flag such that it exits after finishing the current iteration (pseudocode because I'm not familiar with python): while shouldExit = false // do stuff

How can I pass command-line arguments in IronPython?

北战南征 提交于 2019-11-27 08:35:05
问题 I am working with IronPython and have got it working somehow. Though, there seems to be no resource on passing command-line arguments to Iron Python. How can I pass command-line arguments to a python program from my C# code? setup = new ScriptRuntimeSetup(); setup.LanguageSetups.Add(IronPython.Hosting.Python.CreateLanguageSetup(null)); runtime = new ScriptRuntime(setup); runtime.IO.RedirectToConsole(); m_engine = runtime.GetEngine("IronPython"); m_scope = m_engine.CreateScope(); source = m

Ironpython 2.6 .py -> .exe

夙愿已清 提交于 2019-11-27 07:00:47
I already attempted using py2exe (not compatible with ipy) and PYC (out of date). Can anyone point me in the direction of a good compiler? Christian You can use pyc.py , the Python Command-Line Compiler , which is included in IronPython since version 2.6 to compile a Python script to an executable. You find it at %IRONPYTONINSTALLDIR%\Tools\Scripts\pyc.py on your hard disk. Example Let's assume you have a simple script test.py that just prints out something to console. You can turn this into an executable with the following command-line (assuming that the IronPython directory is the current

Iron python, beautiful soup, win32 app

隐身守侯 提交于 2019-11-27 05:05:09
问题 Does beautiful soup work with iron python? If so with which version of iron python? How easy is it to distribute a windows desktop app on .net 2.0 using iron python (mostly c# calling some python code for parsing html)? 回答1: I was asking myself this same question and after struggling to follow advice here and elsewhere to get IronPython and BeautifulSoup to play nicely with my existing code I decided to go looking for an alternative native .NET solution. BeautifulSoup is a wonderful bit of

Script arguments and Embedded IronPython

左心房为你撑大大i 提交于 2019-11-27 04:49:30
问题 I have an embedded scripting engine in my C# application that uses IronPython 2. I create the Python runtime and add a few classes to the global namespace so that the script can import them as modules. However, one (pretty basic) thing I can't figure out is how to send script arguments. I realize that I could just create a variable with a list of arguments, but there must be a proper way to do it. Also, doing it in the proper 'Python' way allows me to compile the scripts and use an automated

Execute query on SQL Server Analysis Services with IronPython

删除回忆录丶 提交于 2019-11-27 02:58:20
问题 I was able to connect to SQL server Analysis service in Python using Microsoft.AnalysisServices.dll , and now I can't execute query on cube. I've tried Execute method same as following: amoServer.Execute('select from finance') After issuing Execute method I have this error: <Microsoft.AnalysisServices.XmlaError object at 0x000000000000002B [Microsoft.AnalysisServices.XmlaError]> Note: I'm using IronPython with Python 2.7 on Windows Server 64Bit. What's the problem? 回答1: its better use

IronPython通过pypyodbc使用SQLAlchemy的方法

醉酒当歌 提交于 2019-11-27 02:43:30
SQLAlchemy是目前在Python界大热的技术,但由于IronPython数据库接口库的缺乏,IronPython却一直无法使用此神器。 现在,借助于纯Python的ODBC接口库pypyodbc,通过简单扩展SQLAlchemy,IronPython也可以用上SQLAlchemy了。 首先为IronPython安装pypyodbc 第一步:直接将pypyodbc.py放置于IronPython的IronPython 2.7\Lib\site-packages\目录下。 然后我们简单扩展SQLAlchemy以支持pypyodbc 第二步:复制IronPython 2.7\Lib\site-packages\sqlalchemy\connectors\pyodbc.py为pypyodbc.py,全文替换所有的pyodbc为pypyodbc 第三步:复制IronPython 2.7\Lib\site-packages\sqlalchemy\dialects\mssql\pyodbc.py为pypyodbc.py,全文替换所有的pyodbc为pypyodbc 第四步:修改IronPython 2.7\Lib\site-packages\sqlalchemy\dialects\mssql\__init__.py, 在import 行最后加入pypyodbc from