Closed robwilkerson closed 9 years ago
What do you get if you run: /usr/local/bin/python /usr/local/bin/pylint --version
?
Hmmm. Using the absolute path, I get the same as above. That seems weird. Why would that be since it's in my PATH
and which
picks up both executables at that location.
Can you cat
the content of /usr/local/bin/pylint
?
I've also seen strange behaviours when there are multiple versions of pylint on a system.
$ cat /usr/local/bin/pylint
#!/usr/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from pylint import run_pylint
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(run_pylint())
pylint < 1.4.0:
# EASY-INSTALL-ENTRY-SCRIPT: 'pylint==1.3.1','console_scripts','pylint'
__requires__ = 'pylint==1.3.1'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pylint==1.3.1', 'console_scripts', 'pylint')()
)
pylint >= 1.4.0:
# -*- coding: utf-8 -*-
import re
import sys
from pylint import run_pylint
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(run_pylint())
So it is notably different..
I have not tested pylint 1.4 at the moment. All I can suggest is to force a reinstall of pylint ...
Note too that pylint is using /usr/bin/python
, whereas your default python is in /usr/local/bin
.
Grr. Used pip to uninstall and reinstall pylint, but it's still using /usr/bin/python
(which is v2.7.6). The Homebrew installed Python is v2.7.9, for whatever that's worth. Am I doing something wrong in my setup? I don't do much Python dev, so there could be nuances of the configuration that I've missed or done incorrectly.
Was your pip installed with /usr/bin/python
or the Homebrew version ?
I'm not sure how that's happening. You could try manually editing the pylint file and changing that to /usr/local/bin/python
.
I'm not sure if the shebang line is important, since sublimelinter forces the use of /usr/local/bin/python
but it's worrth a try !
@NotSqrt To be honest, I'm not sure when/where/how pip was installed. At this point, I can only see that it's using the pip executable in /usr/local/bin/
. A little reading seems to indicate that pip is installed automatically when installing Python via Homebrew. I'm going to try modifying the shebang now and see if that just gets things working.
Well, guess not. I still get the same error(s) after modifying the shebang path. I'm not sure what's going on in my ecosystem that has things all bound up like this.
And behind door #3 was the nuclear option. Uninstall pylint, uninstall all Python versions installed by Homebrew (apparently there were multiple--who knew?), reinstall pip. Apparently this is the price I pay for not having done enough Python development, but things do seem to be working okay using the native OSX Python executable.
Thanks for your help, everyone.
That was definitely a strange problem, no matter what your python experience was ..
Ran into same issue myself having installed python
, pip
and pylint
via Homebrew. As such, the paths to the executables in my python environment were:
python
: /usr/local/bin/python
->
/usr/local/Cellar/python/2.7.12_1/bin/python
(symlink)pylint
: /usr/local/bin/pylint
pip
: /usr/local/bin/pip
->
/usr/local/Cellar/python/2.7.12_1/bin/pip
(symlink)Although my PATH
and PYTHONPATH
settings were correct to prefer the Homebrew python
environment paths, there was one problem:
pylint
executable shim had a shebang line at the top (#!/usr/local/opt/python/bin/python2.7
which pointed to OSX Python.framework
path: /usr/local/opt/python/bin/python2.7
->
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/bin/python2.7
), it was somehow causing a conflict with the runtime environment of pylint
and overriding the Homebrew python.In order to check how the Pylinter Sublime Text Package was starting pylint
, I added a couple debug lines into the Pylinter
code to check what it was using for python_bin
, and pylint_path
:
--- Packages/Pylinter/pylinter.py 2017-01-02 18:15:53.000000000 -0700
+++ Packages/Pylinter/pylinter.py 2017-01-02 18:15:58.000000000 -0700
@@ -178,6 +178,8 @@
try:
python_bin = cls.get_or('python_bin', 'python')
pylint_path = cls.get_or('pylint_path', None)
+ speak("python_bin %s" % python_bin)
+ speak("pylint_path %s" % pylint_path)
if pylint_path is None:
_ = subprocess.Popen("pylint",
stdout=subprocess.PIPE,
The error message in Sublime Text console was:
reloading plugin Pylinter.multiconf
reloading plugin Pylinter.pylinter
reloading plugin SublimeLinter.commands
reloading plugin SublimeLinter.sublimelinter
plugins loaded
SublimeLinter: debug mode: off
SublimeLinter: pylint activated: ('/usr/local/bin/python', '/usr/local/bin/pylint')
- PyLinter: python_bin python
- PyLinter: pylint_path None
- PyLinter: Pylint executable *not* found
- PyLinter: Seaching for lint.py module...
error: Pylinter could not automatically determined the path to `lint.py`.
Please provide one in the settings file using the `pylint_path` variable.
NOTE:
If you are using a Virtualenv, the problem might be resolved by launching Sublime Text from correct Virtualenv.
Traceback (most recent call last):
File "/opt/homebrew-cask/Caskroom/sublime-text3/Build 3083/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 210, in on_api_ready
m.plugin_loaded()
File "/Users/jcuzella/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py", line 78, in plugin_loaded
PYLINT_VERSION = PylSet.get_lint_version()
File "/Users/jcuzella/Library/Application Support/Sublime Text 3/Packages/Pylinter/pylinter.py", line 241, in get_lint_version
command = list(DEFAULT_PYLINT_COMMAND)
TypeError: 'NoneType' object is not iterable
Because I preferred Homebrew for managing my python
and pip
versions, I edited the shim file and replaced the shebang line at the top with: #!/usr/local/bin/python
to force the Homebrew python. Alternatively, it looks like I could have set pylint_path
in my Sublime Text settings somewhere, but I could not get this to work (maybe I did not use the correct setting json variable name or type?).
--- /usr/local/bin/pylint 2017-01-02 18:56:16.000000000 -0700
+++ /usr/local/bin/pylint 2017-01-02 18:56:30.000000000 -0700
@@ -1,4 +1,4 @@
-#!/usr/local/opt/python/bin/python2.7
+#!/usr/local/bin/python
# -*- coding: utf-8 -*-
import re
After the fix, I quit and restarted Sublime Text 3, and in the console, it found pylint
fine this time without pylint_path
set:
reloading plugin PyRefactor.refactor
reloading plugin SublimeLinter-pylint.linter
SublimeLinter: pylint linter loaded
reloading plugin Surround.Surround
reloading plugin JSHint Gutter.JSHint
reloading plugin Pylinter.multiconf
reloading plugin Pylinter.pylinter
reloading plugin SublimeLinter.commands
reloading plugin SublimeLinter.sublimelinter
plugins loaded
- PyLinter: python_bin python
- PyLinter: pylint_path None
- PyLinter: Pylint executable found
- PyLinter: Pylint version (1, 6, 4) found
SublimeLinter: debug mode: off
SublimeLinter: pylint activated: ('/usr/local/bin/python', '/usr/local/bin/pylint')
SublimeLinter: ERROR: pylint cannot locate 'pylint@python'
ApplySyntax: Warning: 'file_name' keyword is deprecated and will be removed in the future.
reloading plugin Pylinter.pylinter
- PyLinter: python_bin python
- PyLinter: pylint_path None
- PyLinter: Pylint executable found
- PyLinter: Pylint version (1, 6, 4) found
I kind of hate creating an issue for this since I'm quite sure it's a me problem (I'm new to Python dev), but it seems like that's the preferred way of asking for help. Anyway, for the life of me, I cannot seem to get this to work. I've been working on this for hours now and reading everything I can find, but either nothing is working or I'm just not understanding it well enough to do it right. I'm hoping someone can point me in the right direction. Don't be afraid to get remedial.
I'm running Sublime Text (build 3065) on OS X. Python 2.7.9 is installed via Homebrew and pylint was installed via
pip install pylint
. I'm working on a few scripts using Python 2.7 and they all begin with#!/usr/bin/env python
.Relevant Console Output
SublimeLinter Settings (
linters > pylint
snippet)Sublime Console Output