My elpy package tells me that it can not find the command "flake8" on a Windows 10 machine.

Ok, it make a bit sense to me. By default there is no flake8 on Windows 10 installed. I was not aware that elpy uses extern commands for syntax checkig of pyton code.

However "flake8" was not automaticly installed by using melpas elpy package. What is the appropriate way to "install" flake8 on a Windows 10? There is no "flake8" on melpa.

3 Answers 3


Make sure the python is installed and its executable could be found. It's required by elpy-rpc-python-command. This should not be a problem if you use the official python installer.

Or else, google "How to Add Python to the Windows PATH variable" so Emacs can find the python executable.

If Emacs still can't find the python executable, you can always set the path of executable to this variable manually:

(setq elpy-rpc-python-command "/usr/bin/python3")

Quoted from elpy,

enter image description here

You might need set python-shell-interpreter from major mode python-mode. It's not part of elpy, but elpy uses it as "Default Python interpreter for shell".

If elpy fails to find the python executable, python-mode fails too. So extra manual setup is required,

 (setq python-shell-interpreter "/usr/bin/python3")

Then set up elpy as its official documentation instructed. Here is my code,

(with-eval-after-load 'python

Elpy requires a few python packages. They are installed into the virtual environment which elpy has created. See https://elpy.readthedocs.io/en/latest/concepts.html#virtual-envs

Add below code and restart Emacs,

(with-eval-after-load 'elpy
  (let ((venv-dir "~/.emacs.d/elpy/rpc-venv"))
    (if (file-exists-p venv-dir) (pyvenv-activate venv-dir))))

All the required python package are automatically installed.

You can double check by M-x elpy-config,

enter image description here

If any package is outdated/missing, check the button I highlighted in screenshot. Click the button to upgrade/install the package.

So your packages for elpy is installed in an independent virtual environment which is only used by elpy.

Extra tip,

After activating the virtual environment created by Elpy, you could also backup its required packages in shell,

source ~/.emacs.d/elpy/rpc-venv/bin/activate && pip freeze > elpy-requirements.txt && deactivate

Then restore the packages in shell,

source ~/.emacs.d/elpy/rpc-venv/bin/activate && pip install -r elpy-requirements.txt && deactivate

"shell" means the bash shell of WSL/Cygwin/MSYS2 on Windows or default bash shell on macOS and Linux.


flake8 is a python package. Simply install it via the Python infrastructur.

On Windows 10

py -3 -m pip install flake8

Also, you may need to add flake8 to the path on windows. I kept trying to reinstall mine and it still wouldn't work until I added it to the path. This will happen especially, if you installed python via the Windows Store.

this will give you the sister dir:

python -m site --user-site

Then use the output and strip off the site-packages part and replace with "Scripts"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.