在执行ctrl+在VS代码(Python)中单击(转到定义)时,如何查看库中的源代码

发布于 2025-02-06 19:05:46 字数 182 浏览 1 评论 0 原文

我知道在VS代码中,我们可以通过CTRL +单击找到变量/函数的定义。 Ctrl + Click还支持我们安装的库中声明的变量/功能(例如Torch,Numpy,..)。

在我的VS代码中,可以使用自己的文件中的“转到定义”,但我无法单击库中定义的变量。

我想要库的变量/功能,也可以通过CTRL+单击搜索。我如何也可用?

I know that in VS Code, we can find the definition of variable/function by ctrl + clicking. Ctrl + click also supports that for variables/functions declared inside the libraries we've installed (e.g. torch, numpy, ..).

In my VS Code, the 'go to definition' in my own file is available, but I can't click variables defined in libraries.

I want variables/functions of libraries also searchable by ctrl+clicking. How do I make it also available?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

乙白 2025-02-13 19:05:46

如果您在虚拟环境中安装库,则应将python解释器更改为 virtualenv 您从VSCODE的右侧使用,然后 Alt+Alt+单击可以帮助您你。

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.

月牙弯弯 2025-02-13 19:05:46

这是塔提供的功能。

您可以安装 pylance> pylance 扩展。

This is a function provided by pylance.

You can install pylance extension.

enter image description here

安稳善良 2025-02-13 19:05:46

就我而言,我必须选择已安装库的正确环境。

只需打开命令调色板( ctrl + p + p p 取决于您的操作系统),然后Enter python:选择解释器:

”

In my case I had to select the correct environment which had the libraries installed.

Simply open the command palette (CTRL+P or +P depending on your OS), then enter Python: Select Interpreter:

select interpreter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文