简体   繁体   English

VS Code - 智能感知各不相同

[英]VS Code - Intellisense varies

I have to admit, I am very stumped and must be missing something obvious.我不得不承认,我很困惑,一定是遗漏了一些明显的东西。

On one user profile on my macbook, VS code works like a dream.在我的 macbook 上的一个用户配置文件中,VS 代码就像做梦一样。 For code like对于像这样的代码

import numpy as np

np.random.

I get code help/completion.我得到代码帮助/完成。 FWIW, I am using a conda environment. FWIW,我使用的是 conda 环境。

When I switch my User to one that I use in class to teach, with a conda environment that matches, and for what I believe are the same extensions installed, Intellisense does not occur.当我将我的用户切换到我在课堂上使用的用户时,使用匹配的 conda 环境,并且我认为安装了相同的扩展,Intellisense 不会发生。

I know that this has been asked, but I have yet to see a clear resolution, and the fact that I am using the same machine, with what I believe is the same setup, is really puzzling.我知道有人问过这个问题,但我还没有看到明确的解决方案,而且我使用的是同一台机器,我认为是相同的设置,这一事实真的令人费解。

Thanks in advance.提前致谢。

According to your description, it is recommended that you try to check the following points:根据您的描述,建议您尝试检查以下几点:

  1. Please check whether the module " numpy " has been successfully installed in the VSCode environment you are currently using.请检查模块“ numpy ”是否已成功安装在您当前使用的VSCode环境中。 Only when this module is installed successfully, VSCode can recognize the method in the module and provide prompts.只有这个模块安装成功,VSCode 才能识别模块中的方法并提供提示。

    在此处输入图片说明

  2. Since the code prompt and completion function in VSCode is provided by the Python extension , it is recommended that you check whether it is installed and available.由于VSCode中的代码提示和补全功能是Python扩展提供的,建议您检查是否安装可用。

In addition, you can try to use the extension " Pylance ", which provides outstanding language service functions and IntelliCode, etc.另外,您可以尝试使用扩展“ Pylance ”,它提供了出色的语言服务功能和IntelliCode等。

Update :更新

The code prompt and completion function provided by different language services are different.不同语言服务提供的代码提示和补全功能是不同的。 Since you want to see randint , rand , random_integers as an option, you can use "python.languageServer":"Jedi", in settings.json .由于您希望看到randintrandrandom_integers作为选项,您可以在settings.json使用"python.languageServer":"Jedi",

在此处输入图片说明

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

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