Accessing fastai library from various locations

This is both a question and a hint :slight_smile:

If creating a new jupyter workbook outside of the fastai repository, you can do this to import the library:

import site

This works for me - I am happy to keep adding this on top of every workbook in the import section and I think this is quite nice so wanted to share.

Here is the question part: using Anaconda, it is recommended to not mess with the PYTHONPATH. Would anyone know if there is some other way of setting this up somewhere to not have to do the site.addsitedir and have this available? I guess I need to symlink something somewhere but I don’t know what to where?


Symlink the fastai dir with the .py modules to the same place as your notebook.


That is a nice solution now that I think of it - once fastai becomes available as a conda / pip install this will not require any code changes, this is much nicer than the solution I found :+1:

I was thinking that maybe there would be somewhere I could symlink from to have the library available globally for any new directories I create - sort of like emulating it being installed while still giving me an ability to automatically reload it.

BTW how to do the symlinking if anyone should wonder:

  1. cd to directory with workbook
  2. ln -s /path/to/fastai_repo/fastai

I’m simply adding fastai to my path as such:

import sys

I like the symlink approach though and may switch to it, but this approach here has served me well thus far (and for any other libraries I have installed but not in my python path).