ModuleNotFoundError: No module named 'fastai'

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

Okay, I tried this running pretty much letter for letter until I got this in step 7: ‘jupyter’ is not recognized as an internal or external command, operable program or batch file.

Not sure how to fix that.

I had this error message whilst running the code from a JupyterLab notebook. Turns out I just had to manually add the “fastai” kernel to the virtual environment created for the course (fastai). This stack overflow answer worked for me:

https://stackoverflow.com/questions/39604271/conda-environments-not-showing-up-in-jupyter-notebook

After activating your fastai environment, simply run this command:
python -m ipykernel install --user --name myenv --display-name “Python (myenv)”

I am using the standard Paperspace Notebook and everything works fine
When I restart the notebook I get the error in Jupyter:

from fastai.imports import *
ModuleNotFoundError: No module named 'fastai'

If I try to activate fastai from the terminal

source activate fastai 

I get

/bin/sh: 14: source: not found

I have read and tried many things so now I hope for a condensed answer.

4 Likes

In each .ipynb project you must add before importing fastai:

import sys
sys.path.append ('../../')
from fastai.imports import *

This way you can import files from other folders, in this case higher folders.

I hope I help you, regards

2 Likes

Hi,
I struggled a lot with installing this package, and it didn’t help that I’m a total noob when it comes to navigating in the command line. Anyway, after trying out a ton of different approaches (and learning a lot on the way), I thought I’d post what eventually solved my problems.

I am using Windows 10. I started out with Anaconda and git installed, and followed Jeremy’s instructions
cd C:\Users\[USERNAME]\Documents\GitHub (or wherever you have your git repo’s)
git clone https://github.com/fastai/fastai
cd fastai
conda create -n fastai python=3.6 anaconda
activate fastai
conda env update

ERROR

Command “python setup.py egg_info” failed with error code 1 in
C:\Users\ [USERNAME]\AppData\Local\Temp\pip- install-6pcncszt\shapely
CondaValueError: pip returned an error

Sources told me this error was caused by pip not being up to date, so I activated the new environment (“fastai”) and upgraded pip

TRY:
(still in the fastai-environment…)
python -m pip install --upgrade pip

This seemes to work. I now tried to run lecture 1 in jupyter notebook. I found out I could also run ipython in the command line to accesses the same python environment as the jupyter notebooks, which made the debugging somewhat easier.

deactivate
conda env update
activate fastai
jupyter notebook

IN JUPYTER NOTEBOOK:
run cell 1 (success)
run cell 2

ERROR:

ModuleNotFoundError: No module named ‘cv2’

I searched around and eventually found the bmatthewtaylor`s guide on Medium

TRY:
From bmatthewtaylor`s guide:

fixing this requires installing with pip and package opencv-python instead of cv2. Not obvious.
pip install opencv-python

ERROR:

ModuleNotFoundError: No module named ‘graphviz’

TRY:
pip install graphviz

ERROR:

ModuleNotFoundError: No module named ‘sklearn_pandas’

TRY:
pip install sklearn_pandas

ERROR:

ModuleNotFoundError: No module named ‘isoweek’

TRY:
pip install isoweek

ERROR:

No module named ‘pandas_summary’

TRY:
From bmatthewtaylor’s guide:

Turns out there are several packages requiring installation.

pip install pandas_summary
pip install torchtext
pip install feather-format
pip install jupyter_contrib_nbextensions
pip install plotnine
pip install docrepr
pip install awscli
pip install kaggle-cli
pip install pdpbox
pip install seaborn

jupyter notebook

IN JUPYTER NOTEBOOK:
run cell 1
run cell 2 ( success!! :smiley: )

Additional changes for Windows:
cell 3: PATH = "data\\bulldozers\\"
cell 4: !dir {PATH}

EDIT: Edited the formating
EDIT 2018-10-11: Corrected a mistake in the commands

1 Like

I followed the course setup for jupyter notebook on www.paperspace.com, but it was erroring out with the error "ModuleNotFoundError: No module named ‘fastai’ ".
To solve this, following code added in notebook (before line from fastai.imports import *)-

import sys
sys.path.append (’…/…/’)

Then I hit another error about directory ‘dogscats’ not found. I looked around and updated the path with following line and it worked. Hope it helps someone.

PATH = “…/…/…/data/dogscats/”

1 Like

Really not working after 1 full week of trial and error on a local machine (DELL M6700 Quadro M4000). Running as developer and running all commands, suggestions, links, etc, etc, etc and no luck. Clean install on clean windows 10 …

Same here. Using paperspace fast.ai notebook on Gradient.

  • First time it Just Works ™.
  • After restarting, I get this error.

Presumably setting the path will fix it, but why the change in behavior?
What is done on the first launch that is not done on the second, and how to fix that?

1 Like

Still, unsatisfying that we have to do this on reload/restart, but not the first time.

Ok, I see my “old card” is not supported… then I will have to upgrade notebook :frowning:

Agreed, same behaviour for me on PAPERSPACE GRADIENT (1/11/18) running FASTAI 0.7. The first time the notebook is opened the dl1 directory has fastai and data installed (as subdirectories of dl1). When the machine is stopped/restarted these subdirectories are gone.

Doing the sys.path.append is an incomplete work around. You then have to change the PATH string further down lesson 1 to find the data (managed to figure that out) and then the model has more problems when you get to the learning step (too complex for me).

I am concluding that there is some setup procedure or environment setting not being restored when the machine is stopped/restarted. Very annoying when you are struggling with “only just enough skills”. JB

I second this. Perhaps this should be mentioned as a possible fix on the Windows setup threat? However, it lead me to a new problem, that is

C:\Users\username\fastai\fastai\courses\dl1\fastai\imports.py in ()
1 from IPython.lib.deepreload import reload as dreload
----> 2 import PIL, os, numpy as np, math, collections, threading, json, bcolz, random, scipy, cv2
3 import pandas as pd, pickle, sys, itertools, string, sys, re, datetime, time, shutil, copy
4 import seaborn as sns, matplotlib
5 import IPython, graphviz, sklearn_pandas, sklearn, warnings, pdb

ModuleNotFoundError: No module named ‘bcolz’

Do I understand correctly that Python is trying to download an external module called “bcolz”, but can’t find it? Does anyone have an idea what the problem could be?

Follow this link for a solution:

1 Like