Elpy: Using ipython with Elpy

Created on 11 Aug 2016  Â·  10Comments  Â·  Source: jorgenschaefer/elpy

Hi,
I am trying to get ipython to be my default interpreter with ELPY.

Here is my current ELPY config:


(add-hook 'python-mode-hook 'elpy-mode)
(with-eval-after-load 'elpy
  (remove-hook 'elpy-modules 'elpy-module-flymake)
  (add-hook 'elpy-mode-hook 'elpy-rpc-python-command "python3")
  (add-hook 'elpy-mode-hook 'flycheck-mode)
  (add-hook 'elpy-mode-hook 'elpy-use-ipython)
  (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save))

After I start emacs, I use the pyvenv-activate command to load my virtualenv with all the required pip packages for ELPY.

I then have to run M-x run-python to get the elpy RPC process to start (Does it not automatically start up?)

When I run C-c C-C to send my code to the REPL it is using the standard Python 3 REPL and not the IPython one.

I am not sure what I am doing wrong to get IPython to be my default REPL.

Here is my ELPY Config

Elpy Configuration


Virtualenv........:  (/Users/gsieran/src/python/dive-into-python3/)
RPC Python........: 3.5.2 (/Users/gsieran/src/python/dive-into-python3/bin/python)
Interactive Python: ipython (/Users/gsieran/src/python/dive-into-python3/bin/ipython)
Emacs.............: 24.5.1
Elpy..............: 1.12.0
Jedi..............: Not found (0.9.0 available)
Rope..............: 0.10.3
Importmagic.......: 0.1.7
Autopep8..........: 1.2.4
Yapf..............: 0.11.0
Syntax checker....: flake8 (/Users/gsieran/src/python/dive-into-python3/bin/flake8)

Thank you for the help

Question

Most helpful comment

are you using ipython3 5.0? if so, add this
(setq python-shell-interpreter "ipython3" python-shell-interpreter-args "--simple-prompt --pprint")

All 10 comments

(elpy-use-ipython "ipython3") would do

Thanks @yitang . I added that to my init.el like so:

(add-hook 'python-mode-hook 'elpy-mode)
(with-eval-after-load 'elpy
  (remove-hook 'elpy-modules 'elpy-module-flymake)
  (add-hook 'elpy-mode-hook 'flycheck-mode)
  (add-hook 'elpy-mode-hook 'elpy-use-ipython "ipython3")
  (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save))

Strangely, my ipython REPL that pops up looks like this:
screen shot 2016-08-11 at 11 59 19 am

Any ideas what is going on here?

are you using ipython3 5.0? if so, add this
(setq python-shell-interpreter "ipython3" python-shell-interpreter-args "--simple-prompt --pprint")

Thanks @yitang that fixed my prompt. Just curious why this is now needed to make the prompt display correctly?

ipython 5 use new terminal interface, see http://emacs.stackexchange.com/questions/24453/weird-shell-output-when-using-ipython-5

Best wishes,

Yi Tang

On 11 Aug 2016, at 18:14, Greg Sierλnski [email protected] wrote:

Thanks @yitang that fixed my prompt. Just curious why this is now needed to make the prompt display correctly?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Thanks @yitang , last question. Every time I start up emacs I need to run M-x run-python so the ELPY RPC process can use it (I believe), is there a way to automatically start this up?

emmmmm. I always have a running Python process when I edit/browser Python scrip, if there's not one, I'd hit c + RET to start one, this would solve the problem.

there are ways to automatically call run-Python but I am not sure this is a good idea in practise. plz check with the author, maybe open a new issue?

Best wishes,

Yi Tang

On 11 Aug 2016, at 18:25, Greg Sierλnski [email protected] wrote:

Thanks @yitang , last question. Every time I start up emacs I need to run M-x run-python so the ELPY RPC process can use it (I believe), is there a way to automatically start this up?

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

Big thanks for all the help!

Nice to see this was handled even without me looking, thanks a lot! :-)

Just a quick note:

Every time I start up emacs I need to run M-x run-python so the ELPY RPC process can use it (I believe), is there a way to automatically start this up?

Elpy's RPC process is completely unrelated to the Python shell start with M-x run-python. You do not need to do M-x run-python to use anything in Elpy.

hey @jorgenschaefer, that's awesome, thanks for letting us know!

Was this page helpful?
0 / 5 - 0 ratings