ModuleNotFoundError: No module named 'fastai'

I am trying to execute the code but getting following error
ModuleNotFoundError: No module named ‘fastai’

6 Likes

You can check your path by typing %pwd and you should see something like this

'/home/user/Documents/fastai/courses/dl1'

You need to check your folder structure to be like this

fastai
-- courses
---- dl1
------ lesson1.ipynb
-- fastai
-- tutorials

If you created another folder in dl1 for example

fastai
-- courses
---- dl1
------ folder
-------- mylesson.ipynb

Then you need to update the path in mylesson.ipynb as following

import sys
sys.path.append("../../fastai/") # go to parent dir
8 Likes

Thanks for reply, folder structure is same as you mentioned above i.e. default structure. I have not made any changes in it.
FYI I am using it on Windows 10.

1 Like

What Python version do you use?

There should be a path issue, I guess. Never tried it on Windows.

The problem is wrong location of the notebook which you are running?

Put all your notebooks in either the ml.or the DL sub directory…

I am opening file from ml folder. No changes in directory structure.

1 Like

sys.version_info(major=3, minor=6, micro=4, releaselevel=‘final’, serial=0)

3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]

Follow step 8 here:

Note that you’ll need to do this every time you do a git pull! (I had everything working for lesson 1 then did a git pull before I started lesson 2 and couldn’t figure out why it wasn’t working until I went back to lesson 1 and realized it was no longer working either!)

10 Likes

Thanks a lot, it worked. please help me with running shell commands from jupyter notebook (windows OS).

!dir {Path}

I have the same problem as you had, No module named ‘fastai’. What did worked for you? you didn’t mention the solution.
I’m running on windows7 but for this step , it should not change something.
I run the file directly where it is located, and i have a path like this,
‘C:\DeepLearning_local\fastai\courses\dl1’
should i change the content of local fastai file located in the dl1 folder maybe?
any idea?

Hello Nilesh can you tell me what changes you made to make it work. As I am too facing the same problem in Windows 10.

we need to create shortcut or windows link of fastai folder in current working folder and remove the existing fasai folder link.

1 Like

Actually I followed the creation of link from both Windows way and as well as mklink way. Still for some reason if seems to not recognize the soft link.
In fact when I created soft link using mklink that Jermey had described, it did not even show me in the directory window.
When I created thru windows folder new link it shows the fastai as link folder.
But none of these options are working.

I had to add sys.path.append("…/…/…/fastai") to make it work but I hate to add extra code in the note book at least while I am starting out.

Thanks for the help down the right path.
I managed to fix the import without adding a sys.path.append by modifying the prescribed windows installation steps from :

mklink /d fastai …\fastai
to
mklink /d fastai …\fastai\

it just wasn’t redirecting to the folder correctly.

I hope that helps someone else.
Cheers

3 Likes

Thanks, it worked for me on windows10 and Anaconda for the DL2 - 2018 course

I installed everything in ubuntu 18.04 but when i run the code it still give import error.
PLEASE HELP

Ubuntu does not support GPU on Windows.
You must follow this guide : Howto: installation on Windows