IPython的笔记本电脑和放大器;脚本的区别 - 加载DLL笔记本电脑、放大器、脚本、加载

由网友(诺言许的快忘的也快)分享简介:使用pythonnet没有人注意到的IPython / Jupyter笔记本/(QT)控制台和普通的Python脚本之间加载.NET的DLL的区别?Did anyone notice the difference in loading .NET dlls between IPython/Jupyter noteboo...

使用pythonnet没有人注意到的IPython / Jupyter笔记本/(QT)控制台和普通的Python脚本之间加载.NET的DLL的区别?

Did anyone notice the difference in loading .NET dlls between IPython/Jupyter notebook/(qt)console and normal python scripts using pythonnet?

这是一个错误/行为引起的pythonnet或IPython的一面?

Is this a bug/behavior caused on pythonnet or ipython side?

这在IPython的和Python交互式控制台:

This works in ipython and python interactive console:

import clr
clr.AddReference(r"C:path2dlldotnetdll")

但在常规的Python脚本时,sys.path中具有与路径,DLL附加:

But in regular python scripts, the sys.path has to be appended with the path to DLL:

import clr
import sys
sys.path.append(r"C:path2dll")
clr.AddReference("dotnetdll")

也许类似的问题:

Possibly similar problem:

OSError只有IPython的,而不是与蟒蛇

推荐答案

在交互模式的Python跨preTER追加空字符串的sys.path 。由于此车AssemblyManager的pythonnet的副作用是只进间preTER模式从完整路径组件。

in interactive mode python interpreter appends empty string "" to sys.path. As a side effect of this the buggy AssemblyManager in pythonnet was loading assemblies from full path only in interpreter mode.

阅读全文

相关推荐

最新文章