简体   繁体   English

VScode 找不到非内置模块的定义

[英]VScode cant find Definitions of non-builtin modules

I am starting to use VScode for developing Python, but I am having some trouble getting some things to works, most importantly I would like to be able to see definitions of functions.我开始使用 VScode 来开发 Python,但是我在使某些事情正常工作时遇到了一些麻烦,最重要的是我希望能够看到函数的定义。 This should work by just hovering on the function (which does work for built-ins, like round()), but does not for imported modules, see the following screenshot: Defintion cant be loaded.这应该通过将鼠标悬停在函数上(它适用于内置函数,如 round())来工作,但不适用于导入的模块,请参见以下屏幕截图:无法加载定义。 For the module itself, I get information when hovering over its name: Description is shown.对于模块本身,将鼠标悬停在其名称上时会获取信息:显示了说明。

It should be noted that I am using a Conda environment, which is noted in my settings.json:需要注意的是,我使用的是 Conda 环境,在我的 settings.json 中注明:

"python.pythonPath": "/home/philip/miniconda3/envs/CV1/bin/python"

"Go to definition" on the function in question yields: "No defintion found for "arange"".相关函数的“转到定义”产生:“未找到“arange”的定义”。 The problem persists both in WSL and Windows 10, with different conda envs.该问题在 WSL 和 Windows 10 中仍然存在,使用不同的 conda 环境。 Is there anything I need to put into my settings I am missing?有什么我需要在我遗漏的设置中添加的吗?

the method numpy.arange is defined in a binary file numpy/core/multiarray and its doc is generated in numpy/add_newdocs.py (line ~1321).方法numpy.arange在二进制文件numpy/core/multiarray ,其文档在numpy/add_newdocs.py (行 ~1321)中生成。

It is a known function because it is defined in an __all__ list in numpy/core/numeric.py这是一个已知函数,因为它是在numpy/core/numeric.py中的__all__列表中定义的

Because there is no def arange() Intellisense has no clue what the arguments are.因为没有def arange() Intellisense 不知道参数是什么。

If you try with a different function defined in numpy/core/numeric.py like ones you get Intellisense on parameters.如果您在定义不同的功能尽量numpy/core/numeric.py喜欢ones ,你在参数获得智能。

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

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