Specs:
To solve unresolved import error in Python, set your Python path in your workspace settings. If you are working with Visual Studio Code and import any library, you will face this error: “unresolved import”. Then reload the VSCode, and it will fix that error.
db' pylint(import-error) showing up. This is because VS Code is not running the Virtual Environment of the app. To fix it, run cmd-shift-p (or click View -> Command Palette and run the command Python: Select Interpreter. VS Code will show you a list of Python interpreters found.
pylint-django is a Pylint plugin for improving code analysis when analysing code using Django. It is also used by the Prospector tool.
Just solved it, thanks to this SO question (VS Code error when importing Django module).
Chances are you installed into a Python environment different from the one you have chosen in VS Code. There are two ways to solve this.
The best solution is to create a virtual environment and then install into it using python -m pip
. You should never use just the straight pip
command as that will install into the last Python you installed which happens to be set earliest in your PATH
.
The other option is to figure out which Python environment you installed Django into and make sure that's the one you have selected in VS Code.
Details on environment selection and such can be found at https://code.visualstudio.com/docs/python/environments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With