ModuleNotFoundError: No module named 'fastai'

(Nilesh Garg) #1

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

(Alessa Bandrabur) #2

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


You need to check your folder structure to be like this

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

If you created another folder in dl1 for example

-- 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

(Nilesh Garg) #3

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.

(Alessa Bandrabur) #4

What Python version do you use?

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

(Aditya) #5

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…

(Nilesh Garg) #6

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

(Nilesh Garg) #7

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

(Nilesh Garg) #8

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!)

(Nilesh Garg) #10

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

(Aditya) #11

!dir {Path}

(Tiri) #12

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,
should i change the content of local fastai file located in the dl1 folder maybe?
any idea?

(Ajay Singh) #13

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.

(Nilesh Garg) #14

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

(Ajay Singh) #15

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.

(Ryan Prosser) #16

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
mklink /d fastai …\fastai\

it just wasn’t redirecting to the folder correctly.

I hope that helps someone else.

(Giancarlo) #17

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

(Sahil Kaushal) #18

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

(Pierre Guillou) #19

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