specify python buffer for interpreter

Asked by Vinh Nguyen

Hi,

I'd like to launch python and ipython remotely by ssh'ing into the remote server in a shell within emacs. I'd like to make this the interactive interpreter in emacs to send my code to from a python file via C-|, etc.

How do I do this? Thanks!

Question information

Language:
English Edit question
Status:
Answered
For:
python-mode.el Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Andreas Roehler (a-roehler) said :
#1

Specifying the remote interpreter via py-shell-name should work. If not, please file a bug-report

Revision history for this message
Vinh Nguyen (vinhdizzo) said :
#2

I think py-shell-name determines which interpreter to launch (path to ipython, python, etc). What I would like to do is launch some python instance (say, M-x shell, ssh into server, then launch python or ipython). From there, I want to specify the buffer name where I could send code from a python file. Thanks!

Revision history for this message
Andreas Roehler (a-roehler) said :
#3

Am 09.04.2013 07:35, schrieb Vinh Nguyen:
> Question #225229 on python-mode.el changed:
> https://answers.launchpad.net/python-mode/+question/225229
>
> Status: Answered => Open
>
> Vinh Nguyen is still having a problem:
> I think py-shell-name determines which interpreter to launch (path to
> ipython, python, etc). What I would like to do is launch some python
> instance (say, M-x shell, ssh into server, then launch python or
> ipython). From there, I want to specify the buffer name where I could
> send code from a python file. Thanks!
>

If working at a remote buffer, that should be detected. Just work as at home.

Revision history for this message
Vinh Nguyen (vinhdizzo) said :
#4

Are you saying it works for you? This is what I tried:

- set py-shell-name to python
- open foo.py
- in another buffer, M-x shell
- ssh into server, start python
- go back to foo.py. evaluate a region of code => a new buffer starts with python started

Revision history for this message
Andreas Roehler (a-roehler) said :
#5

Am 09.04.2013 07:56, schrieb Vinh Nguyen:
> Question #225229 on python-mode.el changed:
> https://answers.launchpad.net/python-mode/+question/225229
>
> Status: Answered => Open
>
> Vinh Nguyen is still having a problem:
> Are you saying it works for you? This is what I tried:
>
> - set py-shell-name to python
> - open foo.py
> - in another buffer, M-x shell
> - ssh into server, start python
> - go back to foo.py. evaluate a region of code => a new buffer starts with python started
>

Then foo.py will be local and send to local executable.
Is foo.py local or remote?

Revision history for this message
Vinh Nguyen (vinhdizzo) said :
#6

foo.py is local in my example.

Revision history for this message
Vinh Nguyen (vinhdizzo) said :
#7

Ahh I see. If foo.py is open remotely, then the python process will be remote.

I guess what I was asking was if I could use a local python file, start a remote python process elsewhere, and still be able to send code.

Guess what I was expecting was being able to specify the buffer name where the code could be sent to...

Revision history for this message
Andreas Roehler (a-roehler) said :
#8

Am 09.04.2013 08:26, schrieb Vinh Nguyen:
> Question #225229 on python-mode.el changed:
> https://answers.launchpad.net/python-mode/+question/225229
>
> Status: Answered => Open
>
> Vinh Nguyen is still having a problem:
> foo.py is local in my example.
>

So you are going to execute a local buffer resp. it's parts through a remote executable?

Revision history for this message
Andreas Roehler (a-roehler) said :
#9

Am 09.04.2013 08:36, schrieb Vinh Nguyen:
> Question #225229 on python-mode.el changed:
> https://answers.launchpad.net/python-mode/+question/225229
>
> Vinh Nguyen posted a new comment:
> Ahh I see. If foo.py is open remotely, then the python process will be
> remote.
>
> I guess what I was asking was if I could use a local python file, start
> a remote python process elsewhere, and still be able to send code.
>

You should be able to. Either specify the shebang in buffer so it points at the remote.
Or leave out shebang --which would precede-- and specify py-shell-name.

Please report errors if not working.

> Guess what I was expecting was being able to specify the buffer name
> where the code could be sent to...
>

Revision history for this message
Vinh Nguyen (vinhdizzo) said :
#10

Can you elaborate? How should the the shebang be specified in the local foo.py file? I tried

#! /ssh:username@hostname#1122:/usr/bin/python

but the python instance that started is from my machine, not the remote host.

Revision history for this message
Andreas Roehler (a-roehler) said :
#11

Created a bug report for this. BTW never saw such a thing, nonetheless it should work.

Please try similar setting py-shell-name

Can you help with this problem?

Provide an answer of your own, or ask Vinh Nguyen for more information if necessary.

To post a message you must log in.