Visual Studio code & Fastai errors

Ok, so now I have spent nearly 3 days trying to fix this issue. I consistently keep getting errors in Visual Studio code about "no name ‘vision’ in module fastai. and ‘unable to import’ whereas I can successfully run Fastai from Jupyter notebook. I have created a new FastAI environment and also selected it in the VS code but it still keeps failing to recognize & load searched every blog & forum including the Troubleshooting section to no avail.

Here are details from fastai.utils run from Jupyter notebooks

=== Software === 
python       : 3.7.3
fastai       : 1.0.61
fastprogress : 0.2.2
torch        : 1.5.1
torch cuda   : None / is **Not available** 

=== Hardware === 
No GPUs available 

=== Environment === 
platform     : Windows-10-10.0.20161-SP0
conda env    : Unknown
python       : C:\ProgramData\Anaconda3\envs\fastai\python.exe
sys.path     : C:\Users\Zyon

no supported gpus found on this system

Why am I so desperate for Visual studio code cause I want to use my exported models and builds app or web-apps and VS Code is a really good IDE. I do have Spyder but I am unable to figure out how to select the correct interpreter.

Has anyone had any success in VS code & fastai? Are they not compatible.
note: I have another machine with GPU but am facing the same error there too.

Which Python interpreter (check the path) is your VS Code using? I don’t use VS Code much, but I think you can select which Python installation to use. I think you will need to use the same one as the one used by Jupyter Notebook (with the fastai installation), and make sure that it loads the same env that contains the fastai installation, i.e. when VS Code’s Python is trying to import fastai, it will and can find it in, say, C:\ProgramData\Anaconda3\envs\fastai\lib\site-packages

Good luck.


Yes, I have changed the VS code interpreters path to use the fastai env. It doesnt complain about from fastai import * and only complains that it cant find the vision module (from import *)

How do I figure out if vision module is installed?
My packages are installed in the users folder.

Something is not right with my environment.

  1. When run python from my fastai env then it open up a 32bit python but I’ve installed a 64bit python from Anaconda 64bit.
  2. I get no errors when I try to import fastai modules from Python as you can see below but I get errors that it cannot find when I try to execute a script from Python.

(fastai) C:\Users\Zhon>C:\Users\Zhon\AppData\Local\Continuum\anaconda3\envs\fastai\python.exe
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>> from fastai import *
>>> from import *
>>> exit()

(fastai) C:\Users\Zhon>python.exe "c:\Users\Zhon\OneDrive\LiveMesh\AI, DS, Python\WebApp\"
Traceback (most recent call last):
  File "c:\Users\Zhon\OneDrive\LiveMesh\AI, DS, Python\WebApp\", line 10, in <module>
    from fastai import *
  File "c:\Users\Zhon\OneDrive\LiveMesh\AI, DS, Python\WebApp\", line 3, in <module>
    import streamlit as st
  File "C:\Users\Zhon\AppData\Local\Continuum\anaconda3\envs\fastai\lib\site-packages\streamlit\", line 102, in <module>
    from streamlit.DeltaGenerator import DeltaGenerator as _DeltaGenerator
  File "C:\Users\Zhon\AppData\Local\Continuum\anaconda3\envs\fastai\lib\site-packages\streamlit\", line 27, in <module>
    from streamlit import caching
  File "C:\Users\Zhon\AppData\Local\Continuum\anaconda3\envs\fastai\lib\site-packages\streamlit\", line 23, in <module>
    import testpickle
  File "c:\Users\Zhon\OneDrive\LiveMesh\AI, DS, Python\WebApp\", line 11, in <module>
    from import *
ModuleNotFoundError: No module named ''; 'fastai' is not a package

you have to be careful how you name your files. It looks like you named it The import mechanism then tries to import vision from there.

1 Like

Thank you, few things solved the prb, I add the following in the PATH environment variable and my other scripts worked but I wasnt able to figure out why my was still failing even though others worked. Then based on your comment I realized that needed to change and the script worked.


I will figure out if there is a way to contribute this info to the troubleshooting help section.

Hey, I recently moved from fastaiv1 to fastaiv2.
I observed a very interesting thing in VS Code. My outline and IntelliSense is not working.It is showing Loading Document Symbol for ... . Initially, I thought it may be a problem with interpreter or something. But I tried all that I could but it is still not working. I changed to the environment having fastaiv1 and it works fine there. I don’t know if its a problem at my end.!

I would like to know if anyone else is facing the same problem

Help would be appreciated.


I have updated my environment containing fastaiv1 to fastaiv2 and again it stopped working.(Initially it was working in the env containing fastaiv1)

After many hours of searching,
I found that fastai is downgrading some packages that vscode uses for intellesense.
Especially npm packages…!
But I still dont know how to fix this!