ModuleNotFoundError: No module named 'fastai'

22,237

Solution 1

So, for another newbie like me, here's what was going on.

Anaconda is its own python environment, it installs its own python packages and python binary, and it changes the PATH so references to python resolve to it instead.

My conda install -C fastai calls had actually not finished successfully, conda list | grep fastai was empty, showing it hadn't installed, and when I tried to reinstall, I actually saw that it fails due to incompatibility / conflict issues with wrapt

I also had jupyter installed thru pip, so it was probably not using anaconda's environment anyway.

I had to create a new environment, reinstall, and then it finally worked!

conda create -n fastai python=3.7 #New blank slate env
conda activate fastai
conda install -c pytorch -c fastai fastai #No erors this time
conda list | grep fastai #It shows up now!

At this point, the previous install of jupyter started breaking, so I reinstalled it with conda install jupyter, and then everything finally worked!

Solution 2

I reinstalled this GitHub version of fastai to correct this problem

pip uninstall fastai

pip install https://github.com/fastai/fastai1/archive/master.zip

Solution 3

I had the same issue, I fixed this by going to the fastai github page https://github.com/fastai/fastai & looking at the latest version.

then i installed it like this:

!pip install fastai==2.2.5
import fastbook
fastbook.setup_book()

I am working through the exercises on Google's Colab at: https://colab.research.google.com/github/fastai/fastbook/blob/master/01_intro.ipynb

Share:
22,237
gregory boero.teyssier
Author by

gregory boero.teyssier

https://ali.actor

Updated on May 08, 2021

Comments

  • gregory boero.teyssier
    gregory boero.teyssier about 3 years

    I'm trying to run the jupyter notebooks of fastai's v3 course. My system has ubuntu 16.04 . Here's what I've done:

    • Installed Python

    • Installed Anaconda

    • Ran

        conda update conda
    
        conda install -c pytorch -c fastai fastai pytorch torchvision cuda92
    
        git clone https://github.com/fastai/course-v3
    
    • The repo is now cloned at /home/ali/ml/course-v3

    • Did cd nbs/dl1, then jupyter notebook

    • Opened the http://localhost:8888/?token=xxxx link from terminal

    However, when I open any of the notebooks, and select any of the import statements, e.g:

    %matplotlib inline
    from fastai.basics import *
    

    I get an error of the following kind:

    ModuleNotFoundError                       Traceback (most recent call last)
    <ipython-input-2-d09c56fdb8ce> in <module>
          1 get_ipython().run_line_magic('matplotlib', 'inline')
    ----> 2 from fastai.basics import *
    
    ModuleNotFoundError: No module named 'fastai'
    

    I've running conda install -c fastai fastai again as indicated on https://course.fast.ai/start_aws.html#step-6-access-fastai-materials but same result.

    None of the other code blocks work of course, giving a NameError on variables not being defined, probably because the initial import didn't work.

    Any ideas what to do / what I'm doing wrong? This is driving me insane..