如何使 VSCode 的自动完成功能与 PyCharm 一样强大?
How to make VSCode's autocomplete as powerful as PyCharm?
问题
我喜欢 VSCode 的外观,但 Python 自动完成功能不太令人满意。
例如,当我导入 numpy
和 plotly.graph_objects
时,VSCode 无法推断出这些模块中的内容:
VSCode doesn't know the linspace fuction
VSCode has completely no idea what's in there and lists some nonmembers. Suggestion may vary from time to time.
虽然 PyCharm 对两个模块都做得很好:
PyCharm knows the linspace function
PyCharm lists the members correctly
我记得 VSCode 曾经和 PyCharm 一样好,但我不知道为什么以及如何使 VSCode 强大再次.
VSCode 配置
Python 扩展设置:
{
"python.jediEnabled": false, // I tried both true and false
"python.analysis.memory.keepLibraryLocalVariables": true,
"python.analysis.memory.keepLibraryAst": true
}
我等待 Python 扩展在后台完全加载和分析。我尝试启用和禁用 Visual Studio IntelliCode 扩展。
如果您尝试了两种语言服务器并且 VS Code 让您重新加载,那么您已经尝试了 Python 扩展中当前可用的选项。不过,我们正在积极努力让它变得更好,并希望很快能对此发表一些看法。
但如果您等不及了,可以尝试 https://marketplace.visualstudio.com/items?itemName=ms-pyright.pyright 作为替代语言服务器。
这可能是与 Pylance 相关的问题。默认情况下,Pylance 仅在根目录中查找模块。在设置中进行一些调整确保我在 VSCode 中导入的所有内容都像在 PyCharm 中导入的一样工作。
请看:
问题
我喜欢 VSCode 的外观,但 Python 自动完成功能不太令人满意。
例如,当我导入 numpy
和 plotly.graph_objects
时,VSCode 无法推断出这些模块中的内容:
VSCode doesn't know the linspace fuction
VSCode has completely no idea what's in there and lists some nonmembers. Suggestion may vary from time to time.
虽然 PyCharm 对两个模块都做得很好:
PyCharm knows the linspace function
PyCharm lists the members correctly
我记得 VSCode 曾经和 PyCharm 一样好,但我不知道为什么以及如何使 VSCode 强大再次.
VSCode 配置
Python 扩展设置:
{
"python.jediEnabled": false, // I tried both true and false
"python.analysis.memory.keepLibraryLocalVariables": true,
"python.analysis.memory.keepLibraryAst": true
}
我等待 Python 扩展在后台完全加载和分析。我尝试启用和禁用 Visual Studio IntelliCode 扩展。
如果您尝试了两种语言服务器并且 VS Code 让您重新加载,那么您已经尝试了 Python 扩展中当前可用的选项。不过,我们正在积极努力让它变得更好,并希望很快能对此发表一些看法。
但如果您等不及了,可以尝试 https://marketplace.visualstudio.com/items?itemName=ms-pyright.pyright 作为替代语言服务器。
这可能是与 Pylance 相关的问题。默认情况下,Pylance 仅在根目录中查找模块。在设置中进行一些调整确保我在 VSCode 中导入的所有内容都像在 PyCharm 中导入的一样工作。
请看: