NameError: name 'defaults' is not defined

Based on Stack Overflow post.

I’m new to fastai.

  • fastai 2.7.5
  • fastcore 1.4.5
  • nbdev 1.2.10
  • torch 1.12.0
  • torchvision 0.13.0

What approaches should I take in trying to resolve such an error like this?

A solution would be greatly appreciated.

Traceback:

(project) daniel@ubuntu-pcs:~/PycharmProjects/project$ python main.py 
Traceback (most recent call last):
  File "/home/daniel/PycharmProjects/project/main.py", line 6, in <module>
    from src.train.train_model import train
  File "/home/daniel/PycharmProjects/project/src/train/train_model.py", line 8, in <module>
    from fastai.vision.all import *
  File "/home/daniel/miniconda3/envs/pdl1lung/lib/python3.9/site-packages/fastai/vision/all.py", line 1, in <module>
    from . import models
  File "/home/daniel/miniconda3/envs/pdl1lung/lib/python3.9/site-packages/fastai/vision/models/__init__.py", line 1, in <module>
    from . import xresnet
  File "/home/daniel/miniconda3/envs/pdl1lung/lib/python3.9/site-packages/fastai/vision/models/xresnet.py", line 17, in <module>
    from ...torch_basics import *
  File "/home/daniel/miniconda3/envs/pdl1lung/lib/python3.9/site-packages/fastai/torch_basics.py", line 11, in <module>
    from .torch_core import *
  File "/home/daniel/miniconda3/envs/pdl1lung/lib/python3.9/site-packages/fastai/torch_core.py", line 31, in <module>
    defaults.benchmark = True
NameError: name 'defaults' is not defined

Code

train_model.py:

...
from fastai.vision.all import *
...
conda create -n venv python==2.6.13
pip install -r requirements.txt

requirements.txt:

fastai==2.5.3
fastcore==1.3.27
python==3.6.13