简体   繁体   English

vscode 智能感知不适用于 PyTorch

[英]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现在即使在我cmd + p > reload window

import torch.nn as nn

I don't get any suggestion righting nn.我没有得到任何纠正nn.建议nn. on vscode 1.31.1在 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我发现jedi是相当缓慢的,但最近公布的Pylance扩建工程就像一个魅力: https://github.com/microsoft/pylance-release

and then update your settings然后更新您的设置

"python.languageServer": "Pylance"

Faced the same problem with vscode 1.42. vscode 1.42 遇到同样的问题。 Resolved the problem by going to Settings , Changing Python: Language server from Microsoft to Jedi .通过转到Settings ,将Python: Language server from Microsoft更改为Jedi解决了该问题。 Now I can see autocomplete with torch.nn .现在我可以看到用torch.nn自动完成。

Using the beta version of the Python language server (0.2.17), I get completions.使用 Python 语言服务器 (0.2.17) 的测试版,我得到了完成。

<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.如果稳定版本不起作用,请按照有关如何下载扩展的测试版以获得完成的说明进行操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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