Import fastai libraries on local machine


(saby) #1

Im trying to install FastAi package in my local windows machine.I got an error message stating no package found.

from fastai.imports import *
from fastai.structured import *

Can some one tell me how to get access to fastai package ?


(Marc Rostock) #2

The symlinks that jeremy uses and work fine on macs and linux failed me too when I tried on windows. In theory it should be possible to create redirect-links in windows too, but in practice this ‚hack‘ also works: Just copy the fastai (library!) folder into the directory from which you run your code. Python looks for modules in the current working directory before searching in other places. This is NOT a clean or recommended solution, but at least it might get you up and running. Beware of the ongoing changes (see other threads regarding git repo), because of the release of fastai v1 the folder you need to use (copy) is the fastai v0.7 version now located in repo fastai/old/fastai.


(saby) #3

Thanks a lot Marc. To make sure im doing the right thing,can you please tell me the below process is correct.
if i run jupyter notebook from my desktop.it would have the default working directory as Desktop.I need to copy all the fastai library to my desktop and run the below statement. in my jupyter notebook

from fastai.imports import *
from fastai.structured import

is it correct?


(Marc Rostock) #4

Hi Saby, not 100% certain what you mean by running it from the desktop. It is important to understand that the directory “jupyter notebook” is run from is the “base” directory and that relative to this python will search, so into that base folder the fastai library folder would have to go. So in your example above that sounds right, but “starting from the desktop” could mean any number of things. To be sure you know where jupyter runs, open a cmd or better anaconda-shell/prompt, then cd in to the directory you want to use as base, activate your environment and then type jupyter notebook manually. Then you know exactly where you started it from and that in that base dir the fastai folder/module will be searched. Btw, this articel shows how to reacreate the symlinks on windows with a command called mklink in order not to copy stuff around:


(saby) #5

sorry for the confusion and thanks for the details.
i created a folder for Fastai courses separately (which is receding in my desktop) from where i would start my jupyter notebook.So my current working directory would be my desktop. since i dont have access to git and conda environment (due to office restirctions), i dont know how to install or activate the fast ai environment.
i tried pip install fastai=0.7. it was unable to install it.
Is there any workaround to use fastai Packages.

Thanks in advance :slight_smile:


#6

Just follow the instructions from Jeremy on this thread:

specifically, step 8:

Replace the linux symlink with a Windows one (note that this requires an admin command prompt if you don’t have a fully updated version of Windows 10):
cd courses\dl1
del fastai
mklink /d fastai ..\..\old\fastai
cd ..\..