问题
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