0

I am trying to update old python code using a TensorFlow v1 container (I will eventually port it to either TensorFlow v2 or PyTorch).

I have an emacs Python environment already set up and used locally based on LSP, pyright, flycheck, pyvenv and anaconda-mode. I have added docker-tramp to use the container environment.

Investigating, I am able to connect emacs to the container and navigate using eShell. However, although I have tried installing pyright in the container using pip install pyright before connecting with tramp-emacs, it appears the install is put in a site-packages folder which isn't in the PATH variable for the container. When I add it prior to connection, pyright still isn't recognised. I can see the folder called pyright and inside a set of python scripts.

As things stand, when I connect to a file of python code in the container (volume mapped to my python workspace), LSP springs to life but advises no language server is available.

Can anyone advise:

How do I set up a container so my Emacs session outside of the container can enter the container and my emacs-lsp can run a Python IDE with pyright using the python and modules in the container?

In answering, can you be sure to address:

  • How should I install pyright so that it can be seen by the docker-tramp connection?
  • If anything else needs installing on the container, are there any 'gotchas' I need to look out for or best practices I should adhere to?

Thanks and regards,

Simon

  • A program outside a container (like Emacs) can't run a program inside a container (like a Python interpreter or an LSP server) without a lot of special setup, which largely isn't in `lsp-mode`. I've had much better luck using a native host development environment (host Ruby/Java/Elixir/... + `M-x lsp-install-server`). – David Maze May 27 '22 at 03:22
  • Thanks @DavidMaze. I hear you regarding the native host development environment. I'm wondering if a VM might be a better solution for me actually. – simon.watson.sjw May 31 '22 at 00:37

1 Answers1

0

Make sure you pyright is in your image/container $PATH, and

(add-to-list 'tramp-remote-path 'tramp-own-remote-path)

Also, there is some issue with lsp-tramp-connection, I don't know whether this PR is enough for tramp-docker.

Tianshu Wang
  • 630
  • 2
  • 9
  • Thanks Tianshu - I did have this in my emacs setup. At present I'm getting an error where emacs reports 'no such file or directory'. It's a long file path but there are no spaces or unusual characters though. I'm thinking I'll park this in the 'too hard' basket for now! Appreciate your advice - thanks for giving it a go. – simon.watson.sjw May 31 '22 at 00:37