Home  >  Article  >  Backend Development  >  How to Fix \"Unresolved Import\" Errors with Pylint in Visual Studio Code?

How to Fix \"Unresolved Import\" Errors with Pylint in Visual Studio Code?

Susan Sarandon
Susan SarandonOriginal
2024-10-28 11:04:15971browse

How to Fix

Resolving "Unresolved Import" Errors with Pylint in Visual Studio Code

In Visual Studio Code, encountering "unresolved import" errors when using Pylint can be frustrating. Here's how to resolve it:

For issues with unresolved default Django imports, the accepted answer provides a solution by adding the global Django installation path to the Visual Studio Code settings.

However, this method may not address errors related to importing custom modules. To resolve this, modify your workspace settings (.vscode/settings.json) by including the following line:

"python.autoComplete.extraPaths": ["path-to-your-code"],

This specifies additional paths where Pylint should search for imported modules.

UPDATE 2023:

With the deprecation of python-language-server, the new closed source LSP Pylance utilizes the following setting:

"python.analysis.extraPaths": ["path-to-your-code"]

By incorporating these settings, you can resolve the "unresolved import" errors and ensure that Pylint accurately detects imported modules within your project.

The above is the detailed content of How to Fix \"Unresolved Import\" Errors with Pylint in Visual Studio Code?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn