snap-stanford / ogb

Benchmark datasets, data loaders, and evaluators for graph machine learning
https://ogb.stanford.edu
MIT License
1.89k stars 398 forks source link

ImportError: cannot import name 'PygGraphPropPredDataset' from 'ogb.graphproppred' #115

Closed tueboesen closed 3 years ago

tueboesen commented 3 years ago

I just installed the package with pip3 install ogb and tried to run the small testscript:


from ogb.graphproppred import PygGraphPropPredDataset
from torch_geometric.data import DataLoader

# Download and process data at './dataset/ogbg_molhiv/'
dataset = PygGraphPropPredDataset(name="ogbg-molhiv", root='dataset/')

split_idx = dataset.get_idx_split()
train_loader = DataLoader(dataset[split_idx["train"]], batch_size=32, shuffle=True)
valid_loader = DataLoader(dataset[split_idx["valid"]], batch_size=32, shuffle=False)
test_loader = DataLoader(dataset[split_idx["test"]], batch_size=32, shuffle=False)

However I receive the following:


Connected to pydev debugger (build 203.7148.72)
Traceback (most recent call last):
  File "/snap/pycharm-community/226/plugins/python-ce/helpers/pydev/pydevd.py", line 1477, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/snap/pycharm-community/226/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/home/tue/.config/JetBrains/PyCharmCE2020.3/scratches/scratch_2.py", line 1, in <module>
    from ogb.graphproppred import PygGraphPropPredDataset
ImportError: cannot import name 'PygGraphPropPredDataset' from 'ogb.graphproppred' (/home/tue/.local/lib/python3.8/site-packages/ogb/graphproppred/__init__.py)
python-BaseException

Process finished with exit code 130 (interrupted by signal 2: SIGINT)

I'm using python 3.8 and should have all the required packages, as far as I can see.

pip3 list
Package                  Version             
------------------------ --------------------
apt-clone                0.2.1               
apturl                   0.5.2               
ase                      3.21.1              
beautifulsoup4           4.8.2               
biopython                1.78                
blinker                  1.4                 
Brlapi                   0.7.0               
certifi                  2019.11.28          
chardet                  3.0.4               
Click                    7.0                 
colorama                 0.4.3               
command-not-found        0.3                 
configobj                5.0.6               
cryptography             2.8                 
cupshelpers              1.0                 
cycler                   0.10.0              
dbus-python              1.2.16              
decorator                4.4.2               
defer                    1.0.6               
distro                   1.4.0               
entrypoints              0.3                 
googledrivedownloader    0.4                 
grpcio                   1.16.1              
h5py                     3.2.1               
httplib2                 0.14.0              
idna                     2.8                 
ifaddr                   0.1.6               
IMDbPY                   6.8                 
indicator-sound-switcher 2.3.5.2             
isal                     0.5.0               
isodate                  0.6.0               
Jinja2                   2.11.3              
joblib                   1.0.1               
kazam                    1.5.3               
keyring                  18.0.1              
kiwisolver               1.3.1               
launchpadlib             1.10.13             
lazr.restfulclient       0.14.2              
lazr.uri                 1.0.3               
littleutils              0.2.2               
llvmlite                 0.35.0              
louis                    3.12.0              
macaroonbakery           1.3.1               
Mako                     1.1.0               
MarkupSafe               1.1.0               
matplotlib               3.3.4               
nemo-emblems             4.8.1               
netifaces                0.10.4              
networkx                 2.5                 
nose                     1.3.7               
numba                    0.52.0              
numpy                    1.20.1              
oauthlib                 3.1.0               
ogb                      1.2.6               
onboard                  1.4.1               
outdated                 0.2.0               
packaging                20.3                
PAM                      0.4.2               
pandas                   1.2.3               
pexpect                  4.6.0               
Pillow                   7.0.0               
pip                      20.0.2              
protobuf                 3.6.1               
psutil                   5.5.1               
pycairo                  1.16.2              
pycrypto                 2.6.1               
pycups                   1.9.73              
pycurl                   7.43.0.2            
PyGObject                3.36.0              
PyICU                    2.4.2               
pyinotify                0.9.6               
PyJWT                    1.7.1               
pymacaroons              0.13.0              
PyNaCl                   1.3.0               
pyparsing                2.4.6               
pyparted                 3.11.2              
pyRFC3339                1.1                 
python-apt               2.0.0+ubuntu0.20.4.4
python-dateutil          2.8.1               
python-debian            0.1.36ubuntu1       
python-louvain           0.15                
python-xapp              2.0.2               
python-xlib              0.23                
pytz                     2019.3              
pyxdg                    0.26                
PyYAML                   5.3.1               
rdflib                   5.0.0               
reportlab                3.5.34              
requests                 2.22.0              
requests-file            1.4.3               
requests-unixsocket      0.2.0               
scikit-learn             0.24.1              
scipy                    1.6.1               
screen-resolution-extra  0.0.0               
SecretStorage            2.3.1               
setproctitle             1.1.10              
setuptools               45.2.0              
simplejson               3.16.0              
six                      1.14.0              
soupsieve                1.9.5               
systemd-python           234                 
threadpoolctl            2.1.0               
tinycss2                 1.0.2               
tldextract               2.2.1               
torch                    1.8.0               
torch-geometric          1.6.3               
torchaudio               0.8.0               
torchvision              0.9.0               
tqdm                     4.59.0              
typing-extensions        3.7.4.3             
ubuntu-advantage-tools   20.3                
ubuntu-drivers-common    0.0.0               
ufw                      0.36                
Unidecode                1.1.1               
urllib3                  1.25.8              
wadllib                  1.3.3               
webencodings             0.5.1               
wheel                    0.34.2              
xkit                     0.0.0               
xopen                    1.1.0               
zeroconf                 0.24.4    
rusty1s commented 3 years ago

It seems that you do not have all required packages installed in order to run PyG. Please follow the installation procedure described here for installing PyG. Alternatively, you can access OGB datasets via

from ogb.graphproppred import GraphPropPredDataset

without any additional library requirements.

KeyHj commented 3 years ago

似乎您没有安装所有必需的软件包才能运行PyG。请按照此处描述的安装步骤安装PyG。或者,您可以通过以下方式访问OGB数据集:

from ogb.graphproppred import GraphPropPredDataset

无需任何其他库要求。

Hello, I can't find a file named "ogbn arXiv" in graphproppreddataset. Which file does this file correspond to in graphproppreddataset?

weihua916 commented 3 years ago

ogbn-arxiv is a node classification dataset.

from ogb.nodeproppred import NodePropPredDataset