title: Why can I run my PyTorch dataset file from a python file but not a notebook?
body: <p>I've written a custom dataset class in PyTorch in a file dataset.py and tried to test it by running the following code in my notebook with the following code:</p>
  <pre><code>from dataset import MyCustomDataset
  from torch.utils.data import DataLoader
  
  ds = MyCustomDataset(&quot;/Volumes/GoogleDrive/MyDrive/MyProject/data/train.pkl&quot;,target_type=&quot;labels&quot;)
  dl = DataLoader(ds,batch_size = 16, shuffle = False)
  X, y = next(iter(dl))
  print(f&quot;X: {X}, y: {y}&quot;)
  </code></pre>
  <p>After some unsuccessful troubleshooting, I tried running the exact same code in a file test.py, which worked without issues!</p>
  <p>Why can't I run this from my notebook?</p>
  <p>For me, the problem is usually the pathing somehow, but in this case, all of the files, both .py, .ipynb and &quot;data&quot;-directory are in the same directory &quot;MyProject&quot;. I've tried with both absolute paths (as in the example) and with relative paths, but it's the same result in both cases. I'm using vscode if that gives any insight.</p>
  <p>Furthermore, the error message in the notebook is &quot;list indices must be integers or slices, not str&quot;, unfortunately, the prompt tells me the wrong lines (there's a comment on the line where the error's supposed to be). But if this is really an error, then it should not work in a python file either, right?</p>
  <p>Any help or suggestions are welcome!</p>