path problem : NameError: name '__file__' is not defined
import os.path as osp
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch_geometric.datasets import MNISTSuperpixels
import torch_geometric.transforms as T
from torch_geometric.data import DataLoader
from torch_geometric.utils import normalized_cut
from torch_geometric.nn import (NNConv, graclus, max_pool, max_pool_x, global_mean_pool)

path = osp.join(osp.dirname(osp.realpath(__file__)), '..', 'data', 'MNIST')

transform = T.Cartesian(cat=False)
train_dataset = MNISTSuperpixels(path, True, transform=transform)
test_dataset = MNISTSuperpixels(path, False, transform=transform)
train_loader = DataLoader(train_dataset, batch_size=64, shuffle=True)
test_loader = DataLoader(test_dataset, batch_size=64, shuffle=False)
d = train_dataset

I'm trying to use MNISTSuperpixels data for graph convolution, but I have some troubles using the example code.
Most of scripts were using
path = osp.join(osp.dirname(osp.realpath(__file__)), '..', 'data', 'MNIST')
However, they gave me an error
NameError: name '__file__' is not defined and I don't understand what osp.realpath(__file__) really means.
I'm using Jupyter notebook on Ubuntu, and my working directory is
print(os.getcwd())
/home/hkimlx/GDL/pytorch_geometric/examples

which is the same directory where the sample code mnist_nn_conv.py is located.
Please help me. Thanks!

In notebook, you need to use double quoted &quot;__file__&quot; as in osp.realpath(&quot;__file__&quot;) instead of osp.realpath(__file__)
Sourced from: https://queirozf.com/entries/python-working-with-paths-the-filesystem#-nameerror-name-'file'-is-not-defined
