Search code examples
python-3.ximporterrorfast-ai

ImportError: cannot import name 'load_learner' from 'fastai'


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
from fastai import load_learner

learn = load_learner('export_2.pkl', cpu=False)

>>> ImportError: cannot import name 'load_learner' from 'fastai' (/home/daniel/miniconda3/envs/pdl1lung/lib/python3.9/site-packages/fastai/__init__.py)

Solution

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

    requirements.txt:

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