简体   繁体   中英

vscode intellisense not working with PyTorch

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

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"

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 .

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

<code>from torch import nn</code> 带补全

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM