ipython notebook & script difference - loading DLLs

随声附和 提交于 2019-12-08 06:33:54

问题


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

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

This works in ipython and python interactive console:

import clr
clr.AddReference(r"C:\path2dll\dotnetdll")

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:

Permission denied on dl.open() with ipython but not with python


回答1:


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.



来源:https://stackoverflow.com/questions/32465864/ipython-notebook-script-difference-loading-dlls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!