I am getting "NameError: name 'train_cats' is not defined"

I am getting the error “NameError: name ‘train_cats’ is not defined”. I have installed fastai version 1.0.34. I have used below code.
from fastai.imports import *
from fastai.tabular import *
##dataframe created by reading data
train_cats(df)
NameError: name ‘train_cats’ is not defined

I’m pretty sure that train_cats() is a function of fast.ai v0.7, not v1’s which is the one you’re using.

Just try install the 0.7 version running pip install fastai==0.7.0

Thank you…I have reinstalled the fast ai version 0.7 and it has resolved it.

1 Like

Are there instructions anywhere on how to do this? I’m running the deep learning course just fine on paperspace. I’m now having problems figuring out how to install the machine learning stuff. I thought of doing that on colab just to keep things separate. However, the instructions for setting up on colab at https://course.fast.ai/start_colab.html seem to be all about deep learning, and therefore would use fastai v 1.0.

I think the alternative would be to set up a separate virtual environment for ml notebooks and v 0.7. But I don’t know how to do that. How are others handling this?

Any help appreciated on how to proceed!

I initially had this problem, too! Turns out you can just set it up locally on your computer in a new virtual environment via conda. If you don’t want to do that, you can run it on an AWS instance instead. Follow the directions here on the Wiki thread for lesson 1. Hope that helps!

@Nafferly, thanks! I’d like to avoid doing it on AWS as I’ve recently shut down my AWS account. I’m pretty sure that the wiki thread for lesson 1 will run version 1.0 of the fast ai library and we’re now supposed to use https://github.com/fastai/fastai/tree/master/old

If you run it locally, are you just using CPU (I’m on a mac)? Does it work well enough?

My computer has a CPU and so far it seems to be working fine, but it’s also worth noting that I am running everything in the fastai-cpu environment, not the regular fastai env. I unintentionally tried to run the random forest lesson in the regular fastai env and nothing worked, lol. I also haven’t tried running the beefier models yet, so we shall see if the rest of the course works okay like this.

i’m getting same error and i research for it and i have solved it by installing dslectures package
by write this comand in cmd
pip install dslectures