5
votes

I'm using a virtual environment and I have selected the right interpreter.

Now even after I cmd + p > reload window and

import torch.nn as nn

I don't get any suggestion righting nn. on vscode 1.31.1

3

3 Answers

8
votes

I found jedi to be quite slow but the recently released Pylance extension works like a charm: https://github.com/microsoft/pylance-release

and then update your settings

"python.languageServer": "Pylance"
2
votes

Faced the same problem with vscode 1.42. Resolved the problem by going to Settings, Changing Python: Language server from Microsoft to Jedi. Now I can see autocomplete with torch.nn.

0
votes

Using the beta version of the Python language server (0.2.17), I get completions.

<code>from torch import nn</code> with completions

To turn on the language server, follow these instructions. If the stable version doesn't work then follow those instructions on how to download the beta version of the extension to get the completions.