Visual Studio Code Pylint: Unable To Import 'protorpc'
Solution 1:
Changing the library path worked for me. Hitting Ctrl + Shift + P
and typing python interpreter
and choosing one of the available shown. One was familiar (as pointed to a virtualenv that was working fine earlier) and it worked. Take note of the version of python you are working with, either 2.7 or 3.x and choose accordingly
Solution 2:
I was facing same issue (VS Code).Resolved by below method
1) Select Interpreter command from the Command Palette (Ctrl+Shift+P)
2) Search for "Select Interpreter"
3) Select the installed python directory
Ref:- https://code.visualstudio.com/docs/python/environments#_select-an-environment
Solution 3:
Open the settings file of your Visual Studio Code (settings.json
) and add the library path to the "python.autoComplete.extraPaths"
list.
"python.autoComplete.extraPaths":["~/google-cloud-sdk/platform/google_appengine/lib/webapp2-2.5.2","~/google-cloud-sdk/platform/google_appengine","~/google-cloud-sdk/lib","~/google-cloud-sdk/platform/google_appengine/lib/endpoints-1.0","~/google-cloud-sdk/platform/google_appengine/lib/protorpc-1.0"],
Solution 4:
For your case, add the following code to vscode's settings.json
.
"python.linting.pylintArgs": [
"--init-hook='import sys; sys.path.append(\"~/google-cloud-sdk/platform/google_appengine/lib\")'"
]
For the other who got troubles with pip packages, you can go with
"python.linting.pylintArgs": [
"--init-hook='import sys; sys.path.append(\"/usr/local/lib/python3.7/dist-packages\")'"
]
You should replace python3.7
above with your python version.
Solution 5:
Spent hours trying to fix the error for importing local modules. Code execution was fine but pylint showed:
Unable to import'<module>'
Finally figured:
First of all, select the correct python path. (In the case of a virtual environment, it will be venv/bin/python). You can do this by hitting
Make sure that your pylint path is the same as the python path you chose in step 1. (You can open VS Code from within the activated venv from terminal so it automatically performs these two steps)
The most important step: Add an empty __init__.py file in the folder that contains your module file. Although python3 does not require this file for importing modules, I think pylint still requires it for linting.
Restart VS Code, the errors should be gone!
Post a Comment for "Visual Studio Code Pylint: Unable To Import 'protorpc'"