PythonNet FileNotFoundException: Unable to find assembly

前端 未结 2 1146
难免孤独
难免孤独 2020-12-30 11:25

I am trying to execute a Python script that uses Python For .Net (https://github.com/pythonnet/pythonnet) to load a C# library called \"Kratos_3.dll\" which is in the same f

相关标签:
2条回答
  • 2020-12-30 11:47

    Another possible reason Python for NET is unable to find lib is different platforms of Python and assemblies. Python 64-bit can't see x86 Dlls, and Python 32-bit can't see x64. Make sure your lib match Python platform, or compile them as AnyCPU.

    0 讨论(0)
  • 2020-12-30 11:56

    It turns out that even though I added the path through

    sys.path.insert(0,"C:\\dev\\proj_1\\")
    

    it still couldn't find the file because the .dll because Windows was not enabling it to load from "external sources". To fix this:

    1. Right-click on the .dll
    2. "Properties"
    3. Under "General", click "Unblock"
    0 讨论(0)
提交回复
热议问题