简体   繁体   English

如何在 vscode (python) 中执行 ctrl+click(go to definition) 时查看库中的源代码

[英]How to see the source code inside the library when doing ctrl+click(go to definition) in vscode (python)

I know that in vscode, we can find the definition of variable/function by ctrl+clicking.我知道在vscode中,我们可以通过ctrl+click找到变量/函数的定义。 Ctrl+click also supports that for variables/functions declared inside the libararies we've installed.(eg torch, numpy, ..) Ctrl+click 还支持在我们安装的库中声明的变量/函数。(例如 torch、numpy、..)

In my vscode, the 'go to definition' in my own file is available, but I can't click variables defined in libraries.在我的 vscode 中,我自己文件中的“转到定义”可用,但我无法单击库中定义的变量。

I want variables/functions of libraries also searchable by ctrl+clicking.我希望库的变量/函数也可以通过 ctrl+clicking 进行搜索。 How do I make it also available?我如何让它也可用?

If you install the libraries in your virtual environments, You should change the python interpreter to your virtualenv that you use from bottom right side of the vscode and then alt+click can help you.如果您在虚拟环境中安装这些库,您应该将 python 解释器更改为您从 vscode 右下角使用的virtualenv ,然后alt+click可以帮助您。

This is a function provided by pylance.这是pylance提供的function。

You can install pylance extension.您可以安装pylance扩展。

在此处输入图像描述

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

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