5

I want to connect to remote ipython server, and follow the doc of the ipython, I start a ipython server in my server by

ipython3 kernel -f ~/.ipython/kernel.json --pprint

and I can start a ipython client in iTerm by

jupyter console --existing path/to/kernel.json --ssh user@192.168.1.111 -simple-prompt

However, I use the above command in emacs by run-python and got

Warning (python): Python shell prompts cannot be detected.
If your emacs session hangs when starting python shells
recover with ‘keyboard-quit’ and then try fixing the
interactive flag for your interpreter by adjusting the
‘python-shell-interpreter-interactive-arg’ or add regexps
matching shell prompts in the directory-local friendly vars:
  + ‘python-shell-prompt-regexp’
  + ‘python-shell-prompt-block-regexp’
  + ‘python-shell-prompt-output-regexp’
Or alternatively in:
  + ‘python-shell-prompt-input-regexps’
  + ‘python-shell-prompt-output-regexps’

The solution in here does not work for me and even if it does, it seems that one can not send code to this *Python* buffer.

So my question is how can I use a remote ipython console and send by codes by python-shell-send-* functions ?

Thanks in advance.

Saddle Point
  • 481
  • 7
  • 23
  • Would it be OK to have Emacs start a remote ipython server, or do you have explicit reasons why you need to connect to an existing one? – Daniel Apr 13 '17 at 18:34
  • @dangom I want to eval the python buffer in a remote powerful machine rather than my local MacBook. – Saddle Point Apr 14 '17 at 01:59

1 Answers1

0

In order to use remote python session, the python file should be on the remote server, and you should call run-python while editing the remote file via tramp. Then python-shell-send-* should work properly.

The reason is, python-shell-send-* will write the code to a tmpfile and then ask the python shell to execute the tmpfile, which needs to be on the same server as the python session.

I've found M-x run-python works without problem for me when editing a remote file via tramp. Connecting to an existing session via (run-python "jupyter console --existing --simple-prompt") also works, it prints the ugly Warning message you posted but is fully functional.

jackkamm
  • 111
  • 3
  • "it prints the ugly Warning message you posted but is fully functional." - does it print `Python shell prompts cannot be detected....` or ``Your `python-shell-interpreter' doesn't seem to support readline, yet `python-shell-completion-native-enable'...``? I wouldn't expect something functional after the first warning. The second can be suppressed by customizing `python-shell-completion-native-disabled-interpreters`. – npostavs Apr 18 '19 at 12:21