Python for .Net Error: ImportError: No module named

好久不见. 提交于 2019-12-12 10:13:38

问题


We are using Python for .Net to call .NET API built using C# from Python script. We are getting ImportError: No module named - error when an import is done as follows.

Python script:

import sys
sys.path.append(r"C:\myfolderA\myfolderB")
print sys.path
import clr
clr.FindAssembly(r"AA.BB.CC")
clr.AddReference(r"AA.BB.CC")
from AA.BB.CC.Api.DDInterface import DDClient

On the above line I am getting following error

Traceback (most recent call last):
  File "C:\myfolderA\myfolderB\testAPI.py", line 7, in <module>
    from AA.BB.CC.Api.DDInterface import DDClient
ImportError: No module named AA.BB.CC.Api.DDInterface

There is no other information available to exactly identify the issue. Dlls from same project built 15 days back works fine. This project may have gone through few changes in between.

How to exactly identify this issue?

Could this be a dependency issue? I tried JustDecompile to compare old dlls and new ones, but couldn't find anything unusual.

Your help is deeply appreciated.

Thanks,


回答1:


With help from python forum I was able to use Microsoft's Fuslogvw.exe (Assembly Binding Log Viewer) and figure out the dependent dll causing the error.

Thanks




回答2:


Here is a link to my original answer:

https://mail.python.org/pipermail/pythondotnet/2014-December/001626.html

I recommend using Assembly Binding Log Viewer (fuslogvw.exe) for corresponding .NET framework to see the log files of loading assemblies.

Set Log Location as Custom and in Settings point to your assemblies folder. The log should show the sequence of DLLs being loaded and any errors.

This worked for me, see here:

Could not load file or assembly or one of its dependencies

Can't locate fuslogvw.exe on my machine



来源:https://stackoverflow.com/questions/27725122/python-for-net-error-importerror-no-module-named

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