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
,

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-enable))
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
,

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.