AttributeError: module 'dgl' has no attribute 'sampling'

I am trying to run from dgl/examples/pytorch/metapath2vec/ and ran into this issue. How to fix it?

Other info:
python 3.6.9 on MacOS and installed dgl (cpu without cuda) using conda.

can any one please help with this?

What’s your dgl version? Could you try the latest version?

Thanks for the reply!!


Yeah I will re-install the latest version and try again.

But, in this version instead of dgl.sampling, I have used random walk method from dgl.contrib… that seem to work fine.

The metapath2vec example is following DGL nightly build, which only recently introduced various sampling methods on heterogeneous graphs in dgl.sampling module.

You can run

  • either the metapath2vec example in 0.4.x branch with 0.4.2, which has the old random walk function (in dgl.contrib.sampling),
  • or the metapath2vec example in master branch with nightly build by installing
    pip install --pre --upgrade dgl   # or dgl-cuxxx for GPU version
    (Just noticed that your machine is MacOS, in which case you’ll have to build from source instead)
1 Like