Using Visual Studio Code with fastai (VSCode bug)

Hello there,

If you would like to use VSCode for FastAI (v2) note that there is currently a bug in the VSCode Python extension (as far as I can tell) that causes the output of anything involving progress bars to be rendered incorrectly. I’ve submitted a bug report that can be tracked here. You can see the result if you try to run the 01_intro.ipynb. It shows up in the first training and causes the result to disappear.

I’ve tried to create a workaround if you would still want to use VSCode. It doesn’t quite work but at least you get some of the output. I’m not sure yet why it doesn’t return all the output.

Paste the following into the notebook before training:

from IPython.display import clear_output, DisplayHandle
def update_patch(self, obj):
DisplayHandle.update = update_patch

If anyone has a better workaround let me know :slight_smile:


Fastai uses the fastprogress library for progress bars. Maybe there needs to be a fix for fastprogress?

Does anyone else have a hard time using VSC to jump around the source code in fastai? I don’t know if it’s the unusual import style or the high degree of misdirection but I can very rarely use the F12 key binding to look something up that exists in the fastai library (sometimes things exist in the fastcore library and my F12 key bindings never work there). fastai is the only library that gives me this problem with such regularity.

I’ve made a pull request to fastprogress, although it really is a bug in VSCode.

1 Like

The PR to fastprogress seems to have stalled along with the bug report. However, the best fix I know of is to run
pip install git+ --force-reinstall
for now


I’ve found that the pylance extension (a new language server for Python) makes code navigation work more reliable, even with the dynamic features that fastai uses.

You’ll need to set the "python.languageServer": "Pylance" setting to use it after installing the extension (like it says in the Quick Start for the extension).