Skip to content

Cannot import TimeSeriesDataSet class in Pythonnet #173

Description

@WezilL

Problem Description---
I'm trying to use the TimeSeriesDataSet class from the TimeSeriesAnalysis library through Pythonnet, but encountering import errors. I've verified in the source code that this class exists in the root namespace (TimeSeriesAnalysis), but I cannot import it in Python.

Error Messages---
When I try to import from the Dynamic sub-namespace:

from TimeSeriesAnalysis.Dynamic import TimeSeriesDataSet
I get:
CopyImportError: cannot import name 'TimeSeriesDataSet' from 'TimeSeriesAnalysis.Dynamic' (unknown location)
When I try to import from the root namespace:
pythonCopyfrom TimeSeriesAnalysis import TimeSeriesDataSet
I get:
CopyImportError: cannot import name 'TimeSeriesDataSet' from 'TimeSeriesAnalysis' (unknown location)

What Works---
I can successfully import other classes from the same library:
pythonCopyfrom TimeSeriesAnalysis.Dynamic import (
    UnitModel,
    UnitParameters,
    ISimulatableModel,
    PidModel,
    PidParameters,
    PlantSimulator,
    SignalType,
)
from TimeSeriesAnalysis.Utility import TimeSeriesCreator

Code Analysis---
I've examined the TimeSeriesDataSet.cs source file and confirmed it's in the root TimeSeriesAnalysis namespace:
csharpCopynamespace TimeSeriesAnalysis
{
    public class TimeSeriesDataSet
    {
        // ...
    }
}

My Code---
pythonCopyimport sys
import pythonnet
pythonnet.load("coreclr")
import clr

assembly_path = r"C:\Users\kyle4des\Desktop\TimeSeriesAnalysis\bin\Debug\netstandard2.0"
sys.path.append(assembly_path)

clr.AddReference("System")
clr.AddReference("System.Collections")
clr.AddReference("Newtonsoft.Json")
clr.AddReference("TimeSeriesAnalysis")

from TimeSeriesAnalysis import TimeSeriesDataSet  # This fails

Questions---
Why can I import other classes but not TimeSeriesDataSet?
Is there a specific way to import this class through Pythonnet?
Could there be an issue with how the class is compiled or exposed in the DLL?
Are there any special attributes or configuration needed for this class to be accessible through Pythonnet?


Environment---
Python 3.9
Pythonnet (latest version)
Using .NET Standard 2.0 DLL

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions