6

My particular setup is that my code lives on my machine and is mounted via vagrant onto a linux container upon which the virtual env lives.

I'd like to be able to edit all the code, including the site-packages which live on the LXC seemlessly and have them all integrated with something like elpy (which is amazing, all credit to those guys) in the context of the virtuall environment which is on the LXC.

How do I do this?

David Boshton
  • 253
  • 2
  • 11
  • 3
    Maybe this will be immediately intuitive for people who know this specific workflow, but for me your question is a bit vague. (1.) If you explained how you access these files *outside* Emacs (is just ssh?), it would be easier to say how Emacs can be used to automate that. (2.) Also, please be very specific with what you mean by *seamlessly*, editing remote files is trivial, loading remote packages is more complicated. (3.) Finally, did you mean to say "elpy" instead of "eply"? :) – Malabarba May 16 '15 at 19:09
  • 1
    Loading remote packages works also trivially. You need to add the remote path where the package resides to `load-path`, like `(setq load-path (cons "/ssh:machine:/path/to/package" load-path))` – Michael Albinus May 19 '15 at 15:19
  • Sounds quite like what I want to do. So I could set that up from a default config and point to the remote site-packages directory giving me all the python libraries I'd use in context? – David Boshton May 19 '15 at 16:35
  • 1
    Should work, yes. Please take care when you use different Emacs versions locally and remotely, there might be compatibility issues. And if a package exists locally and remotely in different versions, the path you want to take the package from shall be prior to the alternative path in `load-path`. – Michael Albinus May 19 '15 at 17:44

2 Answers2

3

No, You can't use a remote virtual environment with emacs with elpy as of now.

Here is jorgenschaefer the author of elpy) comments on this

I'm afraid that won't work. Tramp does a lot of magic with Emacs internals to do what it does, but it breaks in interesting ways if you try to tweak it too far. Elpy does that, because it runs so many different processes and needs to communicate with them in various ways.

So, sorry, elpy does not work with tramp. I can highly recommend not using tramp but use sshfs instead for remote file editing. Or, even better, edit locally and use fab/git to deploy to your VM.

Check this thread for more details https://github.com/jorgenschaefer/pyvenv/issues/26

Chillar Anand
  • 4,042
  • 1
  • 23
  • 52
  • 4
    This is disappointing. Like a lot of devs these days, I write code on my Mac, but run it in various virtual Linux machines via Vagrant, both to keep the environment clean and avoid polluting OS X with lots of dependency cruft. It'd be really nice for Elpy (and tools like it, e.g. robe for Ruby, or irony-mode for C++, for that matter) to support that use case. – dodgethesteamroller Aug 06 '15 at 00:04
  • I don't understand if only elpy + virtualenv + tramp doesn't work, of if elpy + tramp doesn't work. – ppbitb Aug 11 '15 at 17:57
0

anaconda-mode link and its pythonic-activate work with remote virtual environments.