AtomLinter / linter-pylint

Atom linter plugin for Python, using pylint.
60 stars 48 forks source link

linter-pylint not running on MacOS with pyenv (yes, pylint is installed) #257

Open safetymonkey opened 6 years ago

safetymonkey commented 6 years ago

I'm running macOS Sierra. I've installed pyenv using Homebrew, and pyenv has been set to use Python 2.7.14. Pylint is also installed.

$ which python
/Users/<user>/.pyenv/shims/python
$ which pylint
/Users/<user>/.pyenv/shims/pylint
$ which pyenv
/usr/local/bin/pyenv
$ echo $PATH
/opt/bin:/Users/<user>/.rbenv/shims:/Users/<user>/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

I've installed linter-pylint and all the dependencies. I have set the executable path to /Users/<user>/.pyenv/shims/pylint and the Python path to /Users/<user>/.pyenv/shims/python as per above.

When I attempt to run the linter, I see the following error in the developer console:

[Linter] Error running Pylint Error: /usr/local/Cellar/pyenv/1.2.4/libexec/pyenv-exec: /usr/local/bin/pylint: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory
/usr/local/Cellar/pyenv/1.2.4/libexec/pyenv-exec: line 47: /usr/local/bin/pylint: Undefined error: 0
    at Object.<anonymous> (main.js? [sm]:134)
    at Generator.next (<anonymous>)
    at step (/Users/<user>/.atom/packages/linter-pylint/lib/main.js:7)
    at <anonymous>
(anonymous) @ linter-registry.js? [sm]:137

Sure enough, there is no /usr/local/opt/python/bin/python2.7, but I have no idea why linter-pylint is looking there.

$ ls /usr/local/opt/python/bin/python*
/usr/local/opt/python/bin/python3               /usr/local/opt/python/bin/python3.6-config
/usr/local/opt/python/bin/python3-config        /usr/local/opt/python/bin/python3.6m
/usr/local/opt/python/bin/python3.6             /usr/local/opt/python/bin/python3.6m-config

Running pylint directly from my project directory has no issues:

$ pylint --version
Using config file /Users/<user>/Projects/<project>/.pylintrc
pylint 1.9.1,
astroid 1.6.4
Python 2.7.14 (default, May 12 2018, 07:44:15)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]

Any ideas what's going on here?

safetymonkey commented 6 years ago

I think the problem is related to the pyenv global default, which still points at /usr/local/bin/pylint. I have the Working Directory set to %p (and I've even tried hardcoding it to my project directory) but it looks like it's still using the Global pyenv versions, not the ones specified in the working directory. If I set the Global version to 2.7.14 (same as the project) the linter begins to work.

Does anybody know from which directory linter-pylint runs, or have any ideas on how I can get it to call pylint from within the working directory?

sotsugov commented 6 years ago

Please try pyenv rehash

shilgam commented 5 years ago

following configuration works for me:

  "linter-pylint":
    executablePath: "/Users/<your_username>/.pyenv/versions/3.7.1/bin/pylint"
    pythonPath: "/Users/<your_username>/.pyenv/versions/3.7.1/bin/python"

you can find path to your python executable by running in terminal

python -c "import sys; print(sys.executable)"
samdammers commented 5 years ago

@sotsugov suggestion worked like a charm.

I had pyenv installed and a pyenv-virtualenv configured, installed pylint but it was still pointing at the global install. Running pyenv rehash fixed this.

fievelk commented 4 years ago

I'm having the same issue. Using the "dynamic" paths won't work:

/Users/<user>/.pyenv/shims/python
/Users/<user>/.pyenv/shims/pylint

Using pyenv rehash does not solve the issue.

Using specific paths (like below) works, but that's not good because they have to be manually changed for each different pyenv:

/Users/<user>/.pyenv/versions/<pyenv-name>/bin/python
/Users/<user>/.pyenv/versions/<pyenv-name>/bin/python

Any suggestion?