IronPython ImportException: No module named logging(IronPython ImportException:没有名为日志记录的模块)
问题描述
我让 ironpython 在单声道上运行良好,但它没有导入 logging
模块.执行此代码:
I got ironpython working fine on mono, but it doesn't import the logging
module.
Executing this code:
ScriptEngine engine = Python.CreateEngine();
dynamic logging = engine.ImportModule("logging");
产生以下错误:
IronPython.Runtime.Exceptions.ImportException: No module named logging
我包含的 IronPython 程序集是最新的:IronPython.Modules.dll、Microsoft.Dynamic.dll、Microsoft.Scripting.dll、Microsoft.Scripting.Metadata.dll.
The IronPython assemblies I have included are up-to-date: IronPython.Modules.dll, Microsoft.Dynamic.dll, Microsoft.Scripting.dll, Microsoft.Scripting.Metadata.dll.
如何使用 Ironpython 中的日志记录模块?
How can I make use of the logging module within Ironpython?
推荐答案
将程序集添加到 C# 应用程序是不够的.logging
是用 python 编写的,它是标准库的一部分.您还必须将标准库添加到 IRONPYTHONPATH
.你可以这样做:
It's not enough to add the assemblies to your C# application. logging
is written in python, and it's part of the standard library. You'll have to add the standard library to IRONPYTHONPATH
as well. You can do it like this:
var engine = Python.CreateEngine();
var paths = engine.GetSearchPaths();
paths.Add(@"C:Path oyourstandardlibrary");
engine.SetSearchPaths(paths);
如果您需要标准库,您可能需要将它与您的应用程序一起提供.我的建议是压缩它,然后将 zip 文件添加到 paths
.
If you need the standard library you would probably need to ship it with your application. My suggestion is to zip it and then add the zip file to the paths
.
这篇关于IronPython ImportException:没有名为日志记录的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:IronPython ImportException:没有名为日志记录的模块


基础教程推荐
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01