Activate my virtualenv, run vim (in terminal), Syntastic is giving me: syntastic: error: checker python/pylint: can't parse version string (abnormal termination?).
If I run :echo system('pylint --version') in Vim I get:
Traceback (most recent call last):
File "/home/seanh/.virtualenvs/ckan/bin/pylint", line 5, in <module>
from pkg_resources import load_entry_point
File "/home/seanh/.virtualenvs/ckan/lib/python2.7/site-packages/pkg_resources.py", line 2736, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/home/seanh/.virtualenvs/ckan/lib/python2.7/site-packages/pkg_resources.py", line 698, in subscribe
callback(dist)
File "/home/seanh/.virtualenvs/ckan/lib/python2.7/site-packages/pkg_resources.py", line 2736, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/home/seanh/.virtualenvs/ckan/lib/python2.7/site-packages/pkg_resources.py", line 2274, in activate
list(map(declare_namespace, self._get_metadata('namespace_packages.txt')))
File "/home/seanh/.virtualenvs/ckan/lib/python2.7/site-packages/pkg_resources.py", line 1870, in declare_namespace
path = sys.modules[parent].__path__
KeyError: 'repoze.who'
No idea why. But if i quit vim and run pylint --version in a shell in the same terminal (same virtualenv activated) it's fine:
pylint 1.3.1,
astroid 1.2.1, common 0.62.1
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2]
I can also actually get pylint to check a python package and it works fine.
(Running the latest syntastic commit from master: e4c94d67a9ba7f35397b4a2f0daa8f346a84a8b9)
(Ubuntu 14.04)
Weirdly this has just started working on its own now ... No idea what was going on. I'll re-open if it comes back
If you get a traceback simply from calling system('pylint --version') your problem doesn't have anything to do with syntastic. If it happens again perhaps report it to the maintainers of virtualenv?
This only happens when pylint is run from inside vim though, I can't reproduce it in a shell outside of vim. The problem has returned: it happens when pylint is installed in the activated virtualenv and pylint is run from vim. If pylint is not installed in the virtualenv then the pylint installed in my homedir can be run from vim just fine. (Same exact version of pylint installed in my home dir and in the virtualenv.)
$ source .virtualenvs/ckan/bin/activate
(ckan)$ which pylint
/home/seanh/.virtualenvs/ckan/bin/pylint
(ckan)$ pylint --version
pylint 1.3.1,
astroid 1.2.1, common 0.62.1
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2]
(ckan)$ vim
Then inside vim :!which pylint outputs /home/seanh/.virtualenvs/ckan/bin/pylint but :!pylint --version gives the KeyError exception from pylint / pkg_resources.py as above.
Ok, I destroyed my virtualenv and re-created it reinstalling pylint and everything else ... It's working now. But I wonder what caused this and if it'll come back
This only happens when pylint is run from inside vim though, I can't reproduce it in a shell outside of vim.
Will you please stop and think for a few minutes before posting? Thank you. Syntastic is not responsible for vim, virtualenv, or pylint. It doesn't come into play when you run :echo system('pylint --version'). You'd get the same problem if you'd unistall syntastic and run the command again. Please don't bother reopening this.
Nice. I am aware that this is not a bug in syntastic. From syntastic's readme in this repo:
The preferred place for posting suggestions, reporting bugs, and general discussions related to syntastic is the issue tracker at GitHub.
Getting pylint working from inside vim is something that python developers who want to use syntastic need to do. By documenting the problem and solution here, I'm making something that others who have this problem can come across when they search for it.
Python developers who want to use syntastic also need to get their computers powered up. Yet I don't see many posts here about solving problems with power supplies. Which out-strawmans your point hands down, nyah, nyah. :)
Anyway, a search for repoze.who turns out this.
For anyone else who stumbles across this error, the correct approach is probably use the python-mode plugin and disable syntastic with the following so that the two do not conflict on python files:
let g:pymode_lint_on_write = 0
python-mode supports multiple virtualenv and includes pylint and a bunch of other stuff you probably want.
@philbert Well "this error" was actually triggered by repoze.who. Perhps repoze.who has evolved in the mean time. If you have a problem that isn't related to repoze.who, please open a new issue and explain what you did, what did you expect to happen, and what happened instead.
As for python-mode, turning off pymode_lint_on_write actually disables lint checks by python-mode, not syntastic (cf. :h syntastic-pymode). You can use syntastic_mode_map to disable syntastic checks, or any of the other mechanisms documented in the manual. However, python-mode uses the Python interpreter embedded in Vim, and that doesn't necessarily make your life easier when you need to deal with multiple versions of Python. _shrug_
Thanks for the clarification @lcd047. I appreciate that you are so fast to respond on issues.
Getting my setup to do what I want has been a long journey with a lot of small errors along the way, but I had a similar symptom described above, being that pylint worked from the terminal but not inside syntastic but only when I was working in a virtualenv. (But I don't use repoze.who)
I think I may have been misled in your comments here leading me to believe syntastic did not handle virtualenv properly so I figured I'd drop a note to help put others on the right path. But maybe my good intentions were misguided...
@philbert Syntastic relies on Vim being able to run external checkers without crashing them. There are many moving parts (Vim itself, the shell, the OS, external interpreters such as Python, etc.) and getting them to play nice together is not always trivial. What the above says is that syntastic won't work if all these parts are not already playing well together when syntastic comes into play. Syntastic is a Vim plugin, you can't expect it to fix your setup. _shrug_