reddit / emacs

Solutions for remote python development with virtual environment

XtremePocket · 2022-03-17 22:08
One thing I do a lot personally is editing and running python project in remote servers, which almost always come with their own condo environments. I'm currently trying to do this in emacs with python-mode, lsp-mode and conda-mode. The command `conda-activate` works perfectly with lsp on my local machine, but when using tramp, it seems that the same command can only select environments from my local conda, no the remote one. Is there a way around this? Or is this unavoidable? Before getting into emacs, I used vim. Keeping a copy of vim in remote server was easy enough and access through ssh works nicely. If it's impossible to use conda environments on remote, is it possible to create some type of emacs client on remote and run something like graphic ssh?
astoff1 · 2022-03-18 06:18
If you want Tramp to use the same PATH that you would get when logging into the remote interactively (which is \*not\* the default behavior), use this: (connection-local-set-profile-variables 'use-own-path '((tramp-remote-path tramp-own-remote-path "/usr/bin" "/bin"))) (connection-local-set-profiles '(:protocol "ssh") 'use-own-path) Then you can set your PATH in the remote's `.profile` (not `.bashrc`!) in any way you like, say by activating conda. Now, if you need to use switch between different PATH settings in the same remote... let me know if you find a nice way to do it, because I haven't found one. One option, not as automagical as I would wish, is to set `tramp-remote-path` as a dir-local variable.
XtremePocket · 2022-03-19 04:54
Hi, thanks for the complete reply! Could you clarify under which package this should go or whether it works on its own in the init.el file?
astoff1 · 2022-03-19 07:00
It works on its own. You can paste in the scratch buffer and evaluate to test, and then paste in your init.el file to make it permanent. How you organize your init file is up to you :-).