Solve – Pylint unresolved import error in Visual Studio Code

Solve – Pylint unresolved import error in Visual Studio Code is a Python error which occurs for multiple reasons when using Pylint with visual studio code.

In this article I am going to solve the error while I try explaining why the error is popping up in the first place, I will also introduce some solutions which worked for other developers and we will see if those solutions can solve the error in your unique situation.

Explaining the Error : Pylint unresolved import error in Visual Studio Code

The error usually happens when you are trying to use Pylint in visual studio code. There are many solutions that you can try, unlike other python errors there are just too many scenarios where this error occurs.

We will explain each solution one by one.

Bellow I will present multiple solutions some have worked for me and others have worked for other developers.

Solution 1 : edit settings.json

One of the tricks one can try to solve this error quickly is to go to workspace settings. Bellow you can find the path.

                                                                       #
.vscode/settings.json
                                                                       #

Then add the following line bellow.

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

If this does not work, just jump to the next solution and try it.

Solution 2 : edit settings.json again

This solution is similar to the solution above, the line you need to add is just different, start by navigating to workspace settings. This is the path .vscode/settings.json.

Add the line bellow.

                                                                       #
    "python.defaultInterpreterPath": "/path/to/your/venv/bin/python",
                                                                       #

If this solution does not work, please try the next solution.

Solution 3 : edit settings.json for django

Another solution for people who have Django, start by running the command bellow in order to install pylint-django.

                                                                       #
pip install pylint-django
                                                                       #

Similar to the solutions above, start by navigating to workspace settings. Using the path bellow.

                                                                       #
.vscode/settings.json.
                                                                       #

And add the following line.

                                                                       #

"python.linting.pylintArgs": ["--load-plugins=pylint_django", ],
                                                                       #

This should be enough to get rid of the error for good.

Solution 4 : enable .jediEnabled

Another Solution that may work for you is to navigate to the file to which we showed you the path to in the previous solutions.

And delete this line of code.

                                                                       #
    "python.jediEnabled": false
                                                                       #

You can also try replacing Microsoft or Pylance in the file with the line of code bellow.

                                                                       #
"python.languageServer": "Jedi"
                                                                       #

I hope this was enough to solve your issue.

Summing-up

The end, we arrived at the end of this article, I hope my article helped you solve your issue, I am sure there are at least 10 other reasons why this error occurs,

I can not find them all and explain them, this is my best attempt guys, Thank you for reading, cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/