4

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.

  • 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? – dangom Apr 13 '17 at 18:34
  • @dangom I want to eval the python buffer in a remote powerful machine rather than my local MacBook. – Edityouprofile Apr 14 '17 at 1:59
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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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