How can I use configured virtualenv and flake8 settings file (setup.cfg in root of project), for flycheck in emacs?
2 Answers
There are a number of plugins for working with virtualenvs. For example, with pyvenv
installed I can use the pyvenv-workon
command to select a virtualenv from $WORKON_HOME
.
virtualenvwrapper
and python-environment
provide similar support, and all three are available on MELPA.
Flycheck has an option flycheck-flake8rc
:
Configuration file for
`python-flake8'
.
If you have per-project configuration files, it might be easiest to create .dir-locals.el
files in the root of each project that sets flycheck-flake8rc
to the appropriate value, e.g.
((python-mode
(flycheck-flake8rc . "/path/to/setup.cfg")))
I would advise not tracking .dir-locals.el
in whatever version control system you are using, though of course that is up to you.

- 127,765
- 105
- 273
- 257
-
what is "/path/to/setup.cfg" this file? what should it contain? – silgon May 16 '15 at 13:01
-
@silgon, it's a flake8 configuration file. See http://flake8.readthedocs.org/en/latest/config.html. – ChrisGPT was on strike May 16 '15 at 13:12
-
Thanks for the superfast answer. Nevertheless, in the configuration there's no part to insert the virtualenv path. Are there more settings? – silgon May 16 '15 at 13:18
-
@silgon, the configuration file is for the flake8 portion of the question. The virtualenv portion is answered in the first two paragraphs of my answer. – ChrisGPT was on strike May 16 '15 at 13:41
I spent some time to find right solution and decided to implement my own:
This is plugin for flycheck-flake8 checker, simply uses flake8 from required virtualenv and setup.cfg from root of the python project.

- 2,884
- 1
- 17
- 32