“VS Code Python: 无法获取自动导入建议”

huangapple go评论60阅读模式
英文:

VS Code Python: unable to get auto import suggestions

问题

I'm using VS Code on Linux. Auto imports do not work for me.

Here is a screenshot:

“VS Code Python: 无法获取自动导入建议”

However, if I import math, VS Code is able to give suggestions when I type math.. This is my user settings.json:

{
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": false,
    "python.analysis.indexing": true,
    "python.analysis.autoImportCompletions": true,
    "python.testing.pytestArgs": [
        "-vv"
    ],
    "python.testing.pytestEnabled": true,
    "window.zoomLevel": -2
}

I don't have anything in my workspace settings.json. I've installed the ms-python and ms-pyright extensions. Everything should be a relatively recent version. Any ideas?

英文:

I'm using VS Code on Linux. Auto imports do not work for me.

Here is a screenshot:

“VS Code Python: 无法获取自动导入建议”

However, if I import math, VS Code is able to give suggestions when I type math.. This is my user settings.json:

{
    "python.linting.pylintEnabled": false,
    "python.linting.flake8Enabled": false,
    "python.analysis.indexing": true,
    "python.analysis.autoImportCompletions": true,
    "python.testing.pytestArgs": [
        "-vv"
    ],
    "python.testing.pytestEnabled": true,
    "window.zoomLevel": -2
}

I don't have anything in my workspace settings.json. I've installed the ms-python and ms-pyright extensions. Everything should be a relatively recent version. Any ideas?

答案1

得分: 0

I actually was not using Pylance (despite thinking I was). -> 我其实并没有使用Pylance(尽管我以为我在使用)。
I manually installed a Pylance vsix file from the marketplace. -> 我手动安装了一个来自市场的Pylance vsix文件。

I thought I was using Pylance because the Python extension says it will automatically install Pylance and given I didn't change any default settings, I assumed it was on. This was incorrect (though I'm not sure why). -> 我以为我在使用Pylance,因为Python扩展说它会自动安装Pylance,并且因为我没有更改任何默认设置,所以我认为它已经启用了。这是不正确的(尽管我不确定为什么)。

英文:

I actually was not using Pylance (despite thinking I was). I manually installed a Pylance vsix file from the marketplace.

I thought I was using Pylance because the Python extension says it will automatically install Pylance and given I didn't change any default settings, I assumed it was on. This was incorrect (though I'm not sure why).

huangapple
  • 本文由 发表于 2023年5月22日 01:52:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/76301208.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定