0

I am using pythonnet and clr to import a C# .DLL
Folder structure is like this:

|-- project
    |-- foo.py
    |-- folderWithDll
        |-- Common.Dll
        |-- example.py

If I am running cmd from the \\project folder, this will work:

from folderWithDll.example import *  

But when I try this:

import clr
from folderWithDll.Common.APIs import *  

I am met with the following error:

ModuleNotFoundError: No module named 'folderWithDll.Common'  

However if I add folderWithDll to the path with:

sys.path.insert(0, os.getcwd()+'\\folderWithDll')

Then I can just do this and it will work:

from Common.APIs import *

Why can I not import the DLL unless I have its parent folder added to sys.path?

Thank you!

  • Possible duplicate of [How can I use a DLL file from Python?](https://stackoverflow.com/questions/252417/how-can-i-use-a-dll-file-from-python) – frankie567 Sep 25 '19 at 15:01
  • I don't think this is a duplicate, I'm asking specifically for importing a C# .dll, why do I need its direct parent folder? – swindevelopment Sep 25 '19 at 15:25

0 Answers0