Skip to content

Instantly share code, notes, and snippets.

@safijari
Last active March 27, 2024 15:30
Show Gist options
  • Save safijari/4f7fbb189941bf2723462b1c0a863c54 to your computer and use it in GitHub Desktop.
Save safijari/4f7fbb189941bf2723462b1c0a863c54 to your computer and use it in GitHub Desktop.
How to use python from a container for elpy in emacs

Create an executable bash script somewhere which runs your python command, for me this contained

#!/usr/bin/env bash
distrobox enter cv -e ~/.virtualenvs/cv/bin/python3 "$@"

which allows me to use a virtualenv I have in my distrobox container directly. Note the "$@" at the end. This is imperative so that commands like ... -m pip can work.

In your config do

(setq elpy-rpc-python-command "<path-to-that-shell-script>")

And that's it. elpy will run everything through your container now.

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