visual-studio 如何在 Visual Studio 2008 中使用 IronPython

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/502173/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:07:23  来源:igfitidea点击:

How to use IronPython with Visual Studio 2008

visual-studioironpythonironpython-studio

提问by

I've tried using the IronPython integration extension provided by Microsoft. But it does not work with Visual Studio 2008.

我试过使用 Microsoft 提供的 IronPython 集成扩展。但它不适用于 Visual Studio 2008。

Is there a proper VS 2008 IDE extension for IronPython?

IronPython 是否有合适的 VS 2008 IDE 扩展?

回答by sblom

For IronPython 1.1 support (whose syntax mirrors CPython 2.4), I successfully built and installed the sample from the Visual Studio 2008 SDK 1.0with the Professional Edition of Visual Studio 2008 SP1. It will work with any edition from Standard up to Team Suite. It definitely won't work with Express Edition due to limitations built in to Express.

对于 IronPython 1.1 支持(其语法镜像 CPython 2.4),我成功地构建并安装了来自Visual Studio 2008 SDK 1.0和 Visual Studio 2008 SP1 专业版的示例。它适用于从 Standard 到 Team Suite 的任何版本。由于 Express 内置的限制,它绝对不适用于 Express Edition。

For IronPython 2.0 (whose syntax mirrors CPython 2.5), there is currently no good way to write and debug under Visual Studio 2008, and unfortunately, it would be a significant undertaking to adapt IronPython Studioto host IronPython 2.0--one of the big updates in IronPython 2.0 was to base it on the Dynamic Language Runtime, and this breaks the tricks for enabling IntelliSense that were used previously such as static compilation.

对于 IronPython 2.0(其语法镜像 CPython 2.5),目前没有在 Visual Studio 2008 下编写和调试的好方法,不幸的是,将IronPython Studio改编为托管 IronPython 2.0将是一项重大的任务——重大更新之一在 IronPython 2.0 中是基于动态语言运行时,这打破了以前使用的启用 IntelliSense 的技巧,例如静态编译。

回答by ajma

回答by Yuvi

Right now, there is no extension to run IronPython v2.0 on Visual Studio.

目前,没有在 Visual Studio 上运行 IronPython v2.0 的扩展。

回答by SeanB

I'm new to both VS2008 and IronPython (but not Python itself): but it sure looks to me like i'm running IronPython 2.0.1 under VS 2008 Pro, albeit in a rather cumbersome fashion.

我是 VS2008 和 IronPython 的新手(但不是 Python 本身):但在我看来,我确实在 VS 2008 Pro 下运行 IronPython 2.0.1,尽管方式相当繁琐。

  1. Follow the instructions at http://blogs.msdn.com/aaronmar/archive/2006/02/16/533273.aspx, with some modifications: search the MS website for the VS 2008 SDK instead, and the path to the IronPythonIntegration solution is therefore in a slightly different (but predicatable) place.
  2. Following on -- "Then, it should simply be a matter of hitting CTRL+F5 for Build & Run. This will launch Visual Studio using the "Experimental hive".". Yes, this launches anotherVS instance on top of the first one, but thankfully you only have to wait through the build process the first time.
  1. 按照http://blogs.msdn.com/aaronmar/archive/2006/02/16/533273.aspx 上的说明进行一些修改:在 MS 网站上搜索 VS 2008 SDK,以及 IronPythonIntegration 解决方案的路径因此在一个稍微不同(但可以预测)的地方。
  2. 继续 - “那么,它应该只是按 CTRL+F5 进行构建和运行的问题。这将使用“实验配置单元”启动 Visual Studio。”。是的,这会在第一个实例之上启动另一个VS 实例,但幸运的是,您只需在第一次等待构建过程。

The rest of the instructions worked for me: i built a simple test console app, and it worked as i expected. I haven't tried any .Net stuff yet, though.

其余的说明对我有用:我构建了一个简单的测试控制台应用程序,它按我的预期工作。不过,我还没有尝试过任何 .Net 的东西。

Now if there were just an easy way to change sys.path to use the normal Python libraries ...

现在,如果有一种简单的方法可以更改 sys.path 以使用普通的 Python 库......

回答by TechTravelThink

If you are just looking at using IronPython in ASP .NET websites (projects not supported), check out how to install Microsoft ASP.NET Futures (July 2007)

如果您只是想在 ASP .NET 网站(不支持项目)中使用 IronPython,请查看如何安装 Microsoft ASP.NET Futures(2007 年 7 月)

回答by Tawani

string code = @"100 * 2 + 4 / 3";

ScriptEngine engine = Python.CreateEngine();
ScriptSource source =
  engine.CreateScriptSourceFromString(code, SourceCodeKind.Expression);

int res = source.Execute<int>();
Console.WriteLine(res);

For the complete tutorial and example code, check out the following link:

有关完整的教程和示例代码,请查看以下链接:

Extending your C# application with IronPython

使用 IronPython 扩展您的 C# 应用程序

http://blogs.microsoft.co.il/blogs/berniea/archive/2008/12/04/extending-your-c-application-with-ironpython.aspx

http://blogs.microsoft.co.il/blogs/berniea/archive/2008/12/04/extending-your-c-application-with-ironpython.aspx