Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VSCode doesn't find linters installed using a different python #409

Closed
jeffwidman opened this issue Dec 12, 2017 · 5 comments
Closed

VSCode doesn't find linters installed using a different python #409

jeffwidman opened this issue Dec 12, 2017 · 5 comments
Assignees
Labels
area-linting feature-request Request for new features or functionality

Comments

@jeffwidman
Copy link

jeffwidman commented Dec 12, 2017

Environment data

VS Code version: 1.18.1
Python Extension version: 0.8.0
OS and version: OS X Sierra

I have three primary python installations:

  1. /usr/bin/python - this is the system python, and I don't use it, but haven't overwritten the symlink so that I don't break any MacOS functionality.
  2. /usr/local/bin/python2 - installed via homebrew, used when I need to run python2 or create python2 venv's
  3. /usr/local/bin/python3 - installed via homebrew, used when I need to run python3 or create python3 venv's

I normally run flake8, pylint, and pycodestyle as linters, and I typically install them into the primary python that I'm using, which is python2 (work) or python3 (personal).

After installation, I can verify that they are available on the command line:

~ ❯❯❯ which flake8
/usr/local/bin/flake8
~ ❯❯❯ which pydocstyle
/usr/local/bin/pydocstyle
~ ❯❯❯ which pylint
/usr/local/bin/pylint

So I would expect that as soon as I enable these linters in my settings.json, that VSCode python extension could find them, as the default command to trigger them is simply "flake8", "pylint", and "pydocstyle".

However, for some reason this extension isn't picking them up... I keep getting the banner message saying these linters aren't installed.

When I pin the location, then linting starts working fine:

"python.linting.flake8Path": "/usr/local/bin/flake8",
"python.linting.pydocstylePath": "/usr/local/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/bin/pylint"

I spent a while searching this issue tracker, but couldn't find any previous reports of this.

jeffwidman added a commit to jeffwidman/dotfiles that referenced this issue Dec 12, 2017
I had to pin the path because for some reason vscode wasn't finding it... Filed microsoft/vscode-python#409
@brettcannon
Copy link
Member

We are actually about to change this in the next version of the extension to use the linters as installed for the selected interpreter so that e.g. you're running Pylint under Python 2 on Python 2 code when using a Python 2 interpreter. If you want to work around this then you will need to specify the full path to override.

@jeffwidman
Copy link
Author

Hmm... so I saw 0.9.0 was out and I tried this.

The behavior did not change. VSCode still could not find the linters, despite them being easily found with which pylint|flake8|pydocstyle.

It's not like I have a super custom path either, they are sitting in /usr/local/bin/ which is the default path for anyone using Homebrew. The only thing I haven't done is overridden the macOS default python with Homebrew's python2 because shadowing the system python is risky.

Are you sure you don't want to have VSCode have a fallback of checking the system path for the existence of pylint, flake8, pydocstyle etc?

@brettcannon brettcannon added awaiting 1-decision area-linting feature-request Request for new features or functionality and removed closed-wontfix labels Dec 15, 2017
@brettcannon
Copy link
Member

I will re-open this as a feature enhancement request.

@brettcannon
Copy link
Member

So I discussed this with @DonJayamanne as to why it's this way, and it turns out there are legitimate reasons. The key issue is if we use e.g. pylint from the global Python when you're running in a virtual environment it will lead to pylint complaining that it can't find something you have installed in your virtual environment but not your global install (which isn't reachable from your virtual environment unless you flip that on).

Now as you noticed you have an escape hatch through your settings.json file. You can also create your virtual environment with the system packages available if you're okay with the loss of isolation. But we have actually explicitly been moving away from falling back to the global install as you're requesting because there have been issues with trying to make it work that turned out to be brittle and led to more bugs.

@jeffwidman
Copy link
Author

That's very reasonable, thank you.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-linting feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

3 participants