这是一个类似的情况我已经遇到过了几个月前使用pylint的事先pylance:
我的python 3.9x- 脚本(使用VS Codeon Ubuntu 20.04 LTS)从以下自定义“工具”导入开始:
import sys
sys.path.append(
'/home/andylu/Dokumente/Allgemeines_material/Sonstiges/Programming/Python/Scripts/'
)
import General.Misc.general_tools as tools
Run Code Online (Sandbox Code Playgroud)
现在,Pylance声明:
Import "General.Misc.general_tools" could not be resolvedPylance (reportMissingImports)
Run Code Online (Sandbox Code Playgroud)
即使在程序执行期间模块被完美地导入,也会发生这种情况。
因此,为了确保Pylance理解这是一个现有的模块路径,除了sys.path.append(..)- 方法之外,我在settings.json- 文件中添加了以下内容:
{
...
// Possible values: "Jedi", "Pylance", "Microsoft", "None".
"python.languageServer": "Pylance",
// NOTE on changing from microsoft to pylance language server: python.autoComplete.extraPaths --> python.analysis.extraPaths
// Docs: https://github.com/microsoft/pylance-release/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings
"python.analysis.extraPaths": [
"/home/andylu/Dokumente/Allgemeines_material/Sonstiges/Programming/Python/Scripts"
],
... …Run Code Online (Sandbox Code Playgroud) python-import python-3.x visual-studio-code vscode-settings pylance
我正在使用Python开发Windows软件.我在Linux上开发,我正在使用Pylint来检查我的代码.我无法摆脱错误:
F| Unable to import '_winreg'
Run Code Online (Sandbox Code Playgroud)
这很明显 - Linux上的Python没有这个模块.
那么,我必须在我的.pylintrc中放置什么来忽略这个错误?
提前谢谢,奥兹
编辑:
文件说:
:F0401: *Unable to import %r*
Used when pylint has been unable to import a module.
Run Code Online (Sandbox Code Playgroud)
现在我需要找到如何使用它...
部分解决方案:
pylint --disable=F0401 <filename>
Run Code Online (Sandbox Code Playgroud)
我仍在寻找通过.pylintrc做的方法.