1

I'm having trouble getting my elpy setup to work smoothly.

My current config is:

Elpy Configuration

Virtualenv........:  (/home/jeff/Documents/Proj/myenv/bin/)
RPC Python........: 3.7.3 (/usr/bin/python3)
Interactive Python: python (/usr/bin/python)
Emacs.............: 26.1
Elpy..............: 1.28.0
Jedi..............: 0.15.1
Rope..............: 0.14.0
Autopep8..........: 1.4.4
Yapf..............: 0.28.0
Black.............: 19.10b0
Syntax checker....: flake8 (/usr/bin/flake8)

The python interactive interpreter (python) is not installed on the
current virtualenv (/home/jeff/Documents/Proj/myenv/bin/). The
system binary (/usr/bin/python) will be used instead.

[run] python3 -m pip install python

How do I get RPC Python set to use the interpreter in my virtual environment?

0

I stumbled into the same problem while setting up python-emacs on macOS. After a lot of searching found that following works with a bit of manual work. In your config, place following

(use-package pyenv-mode-auto
  :ensure t
  :config
  (let ((workon-home (expand-file-name "~/.pyenv/versions")))
  (setenv "WORKON_HOME" workon-home)
  (setenv "VIRTUALENVWRAPPER_HOOK_DIR" workon-home)))

The part in the config is important. The pyenv-mode-auto doesn't work for me but I use it as a carrier for the setting.

Then activate the correct environments by

pyvenv-workon

which will offer you your virtual environment. This will force the elpy RPC to use the virtual environment.

Caveat - It seems that two projects with different virtual environments don't work with the above setting. I am still investigating this. Update on Caveat - following setting for elpy might work according to the documentation

(add-hook 'elpy-mode-hook (lambda () (elpy-shell-toggle-dedicated-shell 1)))
| improve this answer | |
0

You can set elpy-rpc-virtualenv-path:

Path to the virtualenv used by the RPC.

Can be ‘default (create a dedicated virtualenv .emacs.d/elpy/rpc-venv), ‘system (use the system environment), ‘current (use the currently active environment), a virtualenv path or a function returning a virtualenv path.

If the default virtual environment does not exist, it will be created using elpy-rpc-python-command and populated with the needed packages from elpy-rpc–get-package-list.

Also see elpy-rpc-python-command.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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