ModuleNotFoundError: No module named 'fastai'


(Robert William Babaev) #21

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.


#22

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


(Lars Holmberg) #23

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.


(Alejandro) #24

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


(Viggo Tellefsen Wivestad) #25

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


(Tarun) #26

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