Here are a few titles that fit the content of the article: * \'Unresolved Imports\' Error in Visual Studio Code with Pylint: How to Fix it? * Pylint \'Unresolved Imports\' Error in Visual Studio Code: A Solution for Django

Patricia Arquette
Release: 2024-10-30 22:57:03
Original
585 people have browsed it

以下是几个符合文章内容的标题:

*

"Unresolved import" error for Pylint in Visual Studio Code

When using the following settings, I encountered an "Unresolved import" for Pylint Import" error:

  • macOS v10.14 (Mojave)
  • Python 3.7.1
  • Visual Studio Code 1.30
  • Pylint 2.2.2
  • Django 2.1.4

Even the default Django imports (like from django.db import models), this error will also occur.

Cause

The error may be because Visual Studio Code does not see the Python files of the virtual environment.

Tried solutions

  • Set python.PythonPath in the settings.json file, but it is ignored.
  • Setting python.PythonPath in the global Python settings does not show up either.

Solution

Add the following settings to your module:

"python.autoComplete.extraPaths": ["path-to-your-code"]
Copy after login

Note

2023 Yearly update:

python-language-server is deprecated. The new closed source LSP Pylance is set up as follows:

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

The above is the detailed content of Here are a few titles that fit the content of the article: * \'Unresolved Imports\' Error in Visual Studio Code with Pylint: How to Fix it? * Pylint \'Unresolved Imports\' Error in Visual Studio Code: A Solution for Django. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template