Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running different bins of python #1590

Closed
JurijsNazarovs opened this issue Apr 26, 2019 · 7 comments
Closed

Running different bins of python #1590

JurijsNazarovs opened this issue Apr 26, 2019 · 7 comments

Comments

@JurijsNazarovs
Copy link

Hello,

I am trying to make following work, but not sure how. I have a personal computer, where python3 is located in /usr/bin/python3 . Then i put in my .emacs file following lines:

(setq elpy-rpc-python-command " /usr/bin/python3")
(setq python-shell-interpreter " /usr/bin/python3")

and everything works fine on my pc if I do C-c, C-c.

However, I have to work on some python files in remote server, so I have to open file in emacs using C-x, C-f, /ssh:.... . The problem is that python3 on the remote server is not in /usr/bin/python3. Thus, C-c, C-c doesn't to work.

I tried to add the following lines:

(setq elpy-rpc-python-command " python3")
(setq python-shell-interpreter " python3")

and make an alias for python3 command in the server in .bash_profile, but emacs still not picking it up.

So, could you recommend the way I deal with this situation that no matter where I press C-c, C-c and run a right version of python3.

@galaunay
Copy link
Collaborator

Hi,

With the following configuration:

(setq elpy-rpc-python-command "python3")
(setq python-shell-interpreter "python3")

Elpy will use the first executable named python3 that it will found in your PATH.

So to get what you want, I would add the folder where your python3 binaries is to the PATH.
Something like this in your .bash_profile should do:

PATH=/path/to/python/binaries:$PATH

(on your personal computer it shouldn't be needed, as /usr/bin should already be in your PATH.)

@JurijsNazarovs
Copy link
Author

JurijsNazarovs commented Apr 29, 2019

Hello, thanks for your reply. However, I have added the path to the binary in .bash_profile, or .profile, or .bash_rc and none of that helped. Namely, if i ssh using terminal, then python3 does what it needs to do. But it seems like emacs does not read any of these files when I connect to server using C-x,C-f and ssh. I also have add alias python3 on server in .bash_profile with no success.

@gopar
Copy link
Collaborator

gopar commented Apr 29, 2019

Hey,

Elpy doesn't work with remote files :(

See #276

@galaunay
Copy link
Collaborator

galaunay commented May 4, 2019

@gopar I just tries and it works (at least for me :) ). I think the main problem was dealing with jedi and rope because the rpc is run locally.

@JurijsNazarovs Strange, tramp should read your .profile on connection...
The tramp doc mention something that you could use:

Tramp starts a remote process when a command is executed in a remote file or directory buffer. As of now, these packages have been integrated to work with Tramp: compile.el (commands like compile and grep) and gud.el (gdb or perldb).

For Tramp to find the command on the remote, it must be accessible through the default search path as setup by Tramp upon first connection. Alternatively, use an absolute path or extend tramp-remote-path (see Remote programs):

(add-to-list 'tramp-remote-path "~/bin")
(add-to-list 'tramp-remote-path "/appli/pub/bin")

Is it better with (add-to-list 'tramp-remote-path "/path/to/python/binaries")?

ps: As @gopar said, Elpy's completion and documentation may not work properly on a remote server

@JurijsNazarovs
Copy link
Author

@galaunay

Thanks, but it did not help.

@galaunay
Copy link
Collaborator

galaunay commented May 9, 2019

I am afraid it is more related to Tramp than Elpy, I am running out of ideas.

You could still specify the python interpreter per file, using

# -*- python-shell-interpreter: /path/to/python3; elpy-rpc-python-command: /path/to/python3; -*-

at the beginning of you scripts on your remote machine, or

# Local Variables:
# python-shell-interpreter: /path/to/python3
# elpy-rpc-python-command: /path/to/python3
# End:

at the end.

@galaunay
Copy link
Collaborator

galaunay commented Sep 5, 2019

Please re-open if we can do more about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants