PythonNet FileNotFoundException:无法找到程序集
PythonNet FileNotFoundException: Unable to find assembly
我正在尝试执行 Python 脚本,该脚本使用 Python For .Net (https://github.com/pythonnet/pythonnet) 加载名为 "Kratos_3.dll" 的 C# 库文件夹作为脚本,但找不到文件。
我使用 "pip install pythonnet" 安装了 clr。
这是我的脚本:
import clr
import sys
sys.path.insert(0,"C:\dev\proj_1\")
clr.AddReference("Kratos_3")
我一直收到错误消息
FileNotFoundException: Unable to find assembly 'Kratos_3. at Python.Runtime.CLRModule.AddReference(String name)
当我 运行 使用 IronPython 时,它可以工作,但我想使用常规 Python 2.7 使其工作,我需要做什么?
原来虽然我加了路径通过
sys.path.insert(0,"C:\dev\proj_1\")
它仍然无法找到该文件,因为 .dll 因为 Windows 无法使其从 "external sources" 加载。要解决此问题:
- 右键单击 .dll
- "Properties"
- 在 "General" 下,单击 "Unblock"
NET 无法找到 lib 的另一个可能原因 Python 是 Python 和程序集的不同平台。
Python 64 位看不到 x86 Dll,Python 32 位看不到 x64。确保你的库匹配 Python 平台,或者将它们编译为 AnyCPU。
我正在尝试执行 Python 脚本,该脚本使用 Python For .Net (https://github.com/pythonnet/pythonnet) 加载名为 "Kratos_3.dll" 的 C# 库文件夹作为脚本,但找不到文件。
我使用 "pip install pythonnet" 安装了 clr。
这是我的脚本:
import clr
import sys
sys.path.insert(0,"C:\dev\proj_1\")
clr.AddReference("Kratos_3")
我一直收到错误消息
FileNotFoundException: Unable to find assembly 'Kratos_3. at Python.Runtime.CLRModule.AddReference(String name)
当我 运行 使用 IronPython 时,它可以工作,但我想使用常规 Python 2.7 使其工作,我需要做什么?
原来虽然我加了路径通过
sys.path.insert(0,"C:\dev\proj_1\")
它仍然无法找到该文件,因为 .dll 因为 Windows 无法使其从 "external sources" 加载。要解决此问题:
- 右键单击 .dll
- "Properties"
- 在 "General" 下,单击 "Unblock"
NET 无法找到 lib 的另一个可能原因 Python 是 Python 和程序集的不同平台。 Python 64 位看不到 x86 Dll,Python 32 位看不到 x64。确保你的库匹配 Python 平台,或者将它们编译为 AnyCPU。