jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 262 forks source link

cannot send commands to ipython in virtualenv #1283

Open marty0801 opened 6 years ago

marty0801 commented 6 years ago

elpy-config gives

Virtualenv........:  (/home/marty/proj/geo3/)
RPC Python........: 3.5.2 (/home/marty/proj/geo3/bin/python3)
Interactive Python: ipython (/home/marty/proj/geo3/bin/ipython)
Emacs.............: 24.5.1
Elpy..............: 1.18.0
Jedi..............: 0.11.1
Rope..............: 0.10.7
Autopep8..........: 1.3.4
Yapf..............: 0.20.1
Syntax checker....: flake8 (/home/marty/proj/geo3/bin/flake8)

As you see, ipython is installed only in the virtualenv. The version is 4.2.1.

My workflow is as follows: pyenv-activate to set up the virtualenv elpy-set-project-root to /home//marty/proj/geo3/geo As prescribed in the 'read-the-docs' page I inserted in to my .emacs.d/init.el:

(setq python-shell-interpreter "ipython"
       python-shell-interpreter-args "-i --simple-prompt")

Now C-c C-c returns Python Process not running in the message strip at the bottom of emacs. When I comment out these two lines in init.el and execute C-c C-c, it sends the current buffer to the RPC python instance.

Here is a more verbose excerpt of the Messages buffer:

Making python-shell-interpreter local to *Python* while let-bound!
Making python-shell-interpreter-args local to *Python* while let-bound!
Sent python-shell-completion-setup-code
comint-send-string: Process Python not running
marty0801 commented 6 years ago

Solved by specifying in init.el explicit location of ipython within the virtualenv:

(setq python-shell-interpreter "/home/marty/proj/geo3/bin/ipython3"
      ;;      python-shell-interpreter-args "-i --simple-prompt")
      )

But is there a less hacky way to do this?

galaunay commented 6 years ago

It may be a bug in python-mode.

Does it work when disabling elpy-mode (M-x elpy-mode) and trying to send a something to the python shell (M-x python-shell-send-string then print('ok')) ?