2

I have an app named "diary" in my Django project:

school_diary/
    diary/
        <standart files inside app>
        views.py
        forms.py

Inside my views.py I make this import:

from . import forms

PyLint marks it as error. Here's what I have inside my settings.json:

{
    ...,
    "python.linting.enabled": true,
    "on.linting.pylintEnabled": true,
    "python.linting.lintOnSave": true,
    "python.linting.maxNumberOfProblems": 200,
    "python.linting.pylintPath": "/home/alantheknight/Python/Environments/secenv/bin/pylint",
    "python.pythonPath": "/home/alantheknight/Python/Environments/secenv/bin/python3.7",
    ...

Also, I read about generating .pylintrc, so I ran this command:

$ pylint --generate-rcfile > ~/.pylintrc

Where have I made a mistake?

AlanTheKnight
  • 76
  • 1
  • 7
  • Oh, also I've included `"python.linting.pylint.pylintArgs": ["--load-plugins", "pylint-django"]` into my VSCode settings. – AlanTheKnight May 29 '20 at 11:05

2 Answers2

2

This is a common error that most people come across. You have not installed pylint in the same environment that contains your python packages. The environment selected in VS Code is displayed at the bottom left on the status bar of VS Code.

Take a look at stackoverflow/pylint-unable-to-import-error-how-to-set-pythonpath. and also pythonVSCodeDocs/docs/troubleshooting_linting

Sheraram_Prajapat
  • 589
  • 1
  • 9
  • 27
-1

There is no need to create .pylintrc if You are sure that You just won't mess up Your imports. You can just disable the import errors by using the --disable import-error option.

If You're using Pylint through the console then just add --disable import-error as an option.

If You're using a Pylint code editor plugin then there will probably be a setting where You can define the options.

In PyCharm You'd have to go to put that in Settings -> Other Settings -> Pylint -> Arguments.