Pylint unresolved import error in Visual Studio Code
In your workspace settings, you can set your Python path like this:
{
"python.defaultInterpreterPath": "/path/to/your/venv/bin/python",
}
Unresolved import error in VSCode with PyDev?
According to the information you provided, "Unresolved import: redisPyDev
" is provided by the VS Code extension "PyDev
". If you do not use this extension, please try to "disable" it.
Usually, when we use python in VS Code, many of its functions are provided by the Python extension. When I did not install the module "redis", here is the "unresolved import'redis'" information provided by the python extension:
After we installed the module "redis", then reload VS Code, no errors or warnings are displayed here:
(False) import error warning with global PyLint in virtual environment in Visual Studio Code
Very sorry for my previous answer, I had modified the pylintArgs before, so I have not found out the problem.
You can add this in the settings.json:
"python.envFile": "${workspaceFolder}/.env",
And create a file named .env
under the workspace folder, and add this in it:
PYTHONPATH=/Users/pazifik/.virtualenvs/fun-image-scraper/lib/python3.9/site-packages
Explain:
Although you have selected the virtual environment in the VSCode, and you can find the PYTHONPATH
has been modified in the terminal, but the pylint
did not route through the terminal, so it will not get the modified PYTHONPATH
.
When the terminal settings are used, PYTHONPATH affects any tools that
are run within the terminal by a user, as well as any action the
extension performs for a user that is routed through the terminal such
as debugging. However, in this case when the extension is performing
an action that isn't routed through the terminal, such as the use of a
linter or formatter, then this setting will not have an effect on
module look-up.When PYTHONPATH is set using an .env file, it will affect anything the
extension does on your behalf and actions performed by the debugger,
but it will not affect tools run in the terminal.
You can refer to the official docs.
Python unresolved import VisualStudio
From your comment on pip -V, running "pip install.." in the VS Code terminal will install to Python 3.6. You original posts states you are using Python 3.9.0 and I assume this is displayed in the very bottom left of the VS Code window.
Try to install in the VS Code terminal using the correct version of pip like:
pip3.9 install....
You can also switch to the 3.6 Python interpreter in VS Code
- Click the version 3.9.0 in the bottom left of VS code.
- Ctrl+Shift+P > search Python: Select Interpreter
Related Topics
How to Read a Text File into a List or an Array with Python
How to Have Clusters of Stacked Bars
X, = ... - Is This Trailing Comma the Comma Operator
Using Python Requests with JavaScript Pages
How to Start a Python File While Windows Starts
Editing Specific Line in Text File in Python
Insert Line at Middle of File with Python
Prepend Line to Beginning of a File
How to Delete Rows from a Pandas Dataframe Based on a Conditional Expression
Good Python Modules for Fuzzy String Comparison
How to Get the Logical Xor of Two Variables in Python
Keep Only Date Part When Using Pandas.To_Datetime
How Would You Make a Comma-Separated String from a List of Strings
Resetting Generator Object in Python
Calling a Python Script with Input Within a Python Script Using Subprocess