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

1

There are 1 best solutions below

1
On

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.