Reputation: 508
I want pylint to use python3 for linting in Visual Studio code on Mac (which has both python 2.7 standard and python 3.6).
I've tried changing the path to the python interpreter as per How can I debug Python3 code in Visual Studio Code, to no avail. I keep getting python2 errors instead of python3 errors.
See example code for the problem.
Is there a way I can get pylint to recognize python3 errors?
Upvotes: 10
Views: 11373
Reputation: 54
The simple solution is to just change the first line of the file /home/user_name/.local/bin/pylint
from #!/usr/bin/python2
to #!/usr/bin/python3
If you want more, you can rename this file to pylint2
and have a copy pylint3
where you change the first line to #!/usr/bin/python3
.
Now to use pylint3 from command line you just need to type pylint3 instead of pylint.. also change the directory of pylinter in vscode to /home/user_name/.local/bin/pylint3
explanation
Ok this might be very late and the answer might not be the optimum, but I had the same issue.
By default the path to pylint is /home/user_name/.local/bin/pylint
that is a simple python script working as the entry point to pylint.. even after installing pylint using pip3 this file is not changed and keeps directing to use python2 and therefore the packages installed by pip2 for python2.
So either have separate entry points for each pylint version, or modify this one manually to use the pylint package installed for python3.
Upvotes: 0
Reputation: 508
I finally got it working by installing python3 pylint from the console.
sudo python3 -m pip install -U pylint
Upvotes: 5
Reputation: 204
Upvotes: 18