'Intellisense autocomplete not working for wsl in vscode

I've been setting up vscode as an IDE for python development. I use windows subsystem for linux with my python packages installed through anaconda there.

My problem is that auto completion does not work as expected. For examples, outside of wsl if I am using the numpy package I can get autocompletion:

Autocomplete outside of wsl

However, inside of wsl autocomplete does not find numpy.linalg (as in example above):

Autocomplete inside wsl

Thanks in advance!

edit: I am currently using wsl1 if that information is relavent!



Solution 1:[1]

As mentioned by @Adriana Hernández you need to install the extensions inside WSL too.

The VSCode WSL docs are covering these here

In short if you go to the extensions tab, you shall see Python marked with "Install in WSL...". Once clicked install and reloaded, it should work. If not you likely need to pick another interpreter (likely the one from your venv.)

hit Ctrl+Shift+P then

  • Python: Select interpreter
  • then select the desired python interpreter (most likely the one in your venv which has all the packages)

What works for me is creating a venv, activating then launching VSCode from WSL with code . On the first time you will need to install your extensions to WSL, but then it should be good to go.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 CJ Harmath