Module 'dgl' has no attribute 'heterograph'

When I try to construct heterograph using dgl by official website coding, I find this error:

import dgl
import torch as th
# Create a heterograph with 3 node types and 3 edges types.
graph_data = {
   ('drug', 'interacts', 'drug'): (th.tensor([0, 1]), th.tensor([1, 2])),
   ('drug', 'interacts', 'gene'): (th.tensor([0, 1]), th.tensor([2, 3])),
   ('drug', 'treats', 'disease'): (th.tensor([1]), th.tensor([2]))
}
g = dgl.heterograph(graph_data)
g.ntypes
g.etypes
g.canonical_etypes

The error is:
module 'dgl' has no attribute 'heterograph'

How to solve it? I update dgl into 1.1.0, still does not work

Looks like your environment is polluted, try uninstall the DGL first and then reinstall.

yes, I uninstall dgl and torch, update to the latest version. thanks bro :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.