gpt4 book ai didi

python - vscode 中的 pylint 导入错误,即使 python 执行器成功导入它

转载 作者:太空宇宙 更新时间:2023-11-03 15:35:14 24 4
gpt4 key购买 nike

我正在使用 vscode 编写我的 python 代码。我在代码中使用 pandas、numpy 和 requests 库。如果我运行代码,它工作正常。但是在 VScode 编辑器中,在问题部分,它总是说消息为

Unable to import 'numpy' (pylint import error)
Unable to import 'pandas' (pylint import error)
Unable to import 'requests' (pylint import error)

我在 StackOverflow 问题中搜索以找到此问题的答案,它说使用 pip 安装 pandas。我也这样做了。但我仍然面临着同样的问题。如何在 vs 代码编辑器中解决这个问题

最佳答案

这并不是告诉您未安装 numpypandas。它告诉您 pylint 无法验证您的 numpypandas 调用。大多数 numpypandas 都是用 C 语言而不是 Python 编写的。

pylint documentation

Linting C extension modules is not supported out of the box, especially since pylint has no way to get an AST object out of the extension module.

所以你的代码没有问题,即使 VSCode 说这是一个问题。这是 pylint 的技术限制。如果您担心,请为这些 import 语句禁用 pylint 消息 E401。将 #pylint: disable=E401 与您的 import 语句放在同一行。

关于python - vscode 中的 pylint 导入错误,即使 python 执行器成功导入它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55158417/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com