.. unable to import 'xxx' ..
Solution 1: (configure workspace settings to point to fully qualified python executable):
"python.pythonPath": "/users/xxx/bin/python"
Solution 2: (open VS Code from an activated virtual environment):
pip install pylint
Listing could fail due to a number of reasons. Please check each of the following.
Cause: The path to the python executable is incorrect
Solution: Configure the path to the python executable in the settings.json
Cause: The linter has not been installed in the Python environment being used
Solution: Identify the Python environment (executable) configured in settings.json. Next install the linter(s) against this Python environment (use the corresponding Pip).
Cause: The Path to the linter is incorrect
Solution: If you have provided a custom path to the linter in settings.json, then ensure this file path exist.
For further information on configuring Linters can be found here.
It is possible you would like to ignore certain linter messages. This could be done easily.
Generally most linters support configuration files, hence all you need to do is create the relevant configuration file and ignore the appropriate error message.
If on the other hand the linters support the ability to ignore certain messages via command line args, this can be done as well.
Solution: Add relevant command line args to ignore certain messages
Here we’ll assume you use a TAB character as indentation of python code instead of 4 or 2 spaces.
Pylint would generally display a warning for this with the error code W0312.
In order to disable this particular message all one needs to do is as follows in the settings.json file:
"python.linting.pylintArgs": [
"--disable=W0312"
],
Note: You could apply the above configuration settings in your user settings
file, so that it applies to all workspaces.
This saves you from having to define these settings for every single workspace (every time).
For further information on configuring Linters can be found here.
.. unable to import 'xxx' ..
Solution 1: (configure workspace settings to point to fully qualified python executable):
"python.pythonPath": "/users/xxx/bin/python"
Solution 2: (open VS Code from an activated virtual environment):
pip install pylint
Listing could fail due to a number of reasons. Please check each of the following.
Cause: The path to the python executable is incorrect
Solution: Configure the path to the python executable in the settings.json
Cause: The linter has not been installed in the Python environment being used
Solution: Identify the Python environment (executable) configured in settings.json. Next install the linter(s) against this Python environment (use the corresponding Pip).
Cause: The Path to the linter is incorrect
Solution: If you have provided a custom path to the linter in settings.json, then ensure this file path exist.
For further information on configuring Linters can be found here.
It is possible you would like to ignore certain linter messages. This could be done easily.
Generally most linters support configuration files, hence all you need to do is create the relevant configuration file and ignore the appropriate error message.
If on the other hand the linters support the ability to ignore certain messages via command line args, this can be done as well.
Solution: Add relevant command line args to ignore certain messages
Here we’ll assume you use a TAB character as indentation of python code instead of 4 or 2 spaces.
Pylint would generally display a warning for this with the error code W0312.
In order to disable this particular message all one needs to do is as follows in the settings.json file:
"python.linting.pylintArgs": [
"--disable=W0312"
],
Note: You could apply the above configuration settings in your user settings
file, so that it applies to all workspaces.
This saves you from having to define these settings for every single workspace (every time).
For further information on configuring Linters can be found here.