Pythonnet importing class: "ModuleNotFoundError: No module named..."

Viewed 265

I am importing a C# dll into python using pythonnet.

import sys
import clr
assemblydir = r"C:\Users\Nathan_Dehnel\source\repos\TFSHygiene\bin\Debug\net5.0-windows"
sys.path.append(assemblydir)
clr.AddReference("TFSHygiene")
from TFSHygiene import QueryExecutor

The DLL is present inside assemblydir.

Inside TFSHygiene:

namespace TFSHygiene
{
    public class QueryExecutor
    {
        ...
    }
}

I followed the answer in this question: "No module named" error when attempting to importing c# dll using Python.NET

However I get this error when building:

Traceback (most recent call last):
  File "C:\Users\Nathan_Dehnel\OneDrive - Dell Technologies\Documents\ADO TFS\ADO TFS\main.py", line 12, in <module>
    from TFSHygiene import QueryExecutor
ModuleNotFoundError: No module named 'TFSHygiene'

Built with .NET 5.0 target.

1 Answers
Related