如何为远程 Python Fabric Access 获取正确的 $PATH?

How do I get the correct $PATHs for remote Python Fabric Access?

我正在编写一个 python 程序来建立到服务器的 ssh 连接。 为此,我正在使用织物 (fabfile.org)。

当我在终端中通过 ssh 连接到服务器时,我设置了 $PATHs。 当我在 python 程序中通过 fabric 连接到服务器时,$PATH 丢失...

  1. 当我通过终端连接时,bash 在哪里加载 $PATH?
  2. 我如何管理该结构做同样的事情?

提前致谢!

编辑: 这就是我得到的,当我 运行 echo -e ${PATH//:/\n}:

通过终端 SSH:

/home/myusername/bin
/home/myusername/.local/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-11.1.0/mpich-3.4.2-npjoxvgsi2nthnyp5shm42is7wzxdll7/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-11.1.0/libfabric-1.12.1-mzleboxdvvcdtdwg7qg6wf54xwvsmyoz/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-11.1.0/rdma-core-34.0-rf4h4kiatax6su3acacuxu33vxpq5mh4/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-11.1.0/libnl-3.3.0-ih7pa4rn4nuvraaomc4c2ou6f2opyyve/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-11.1.0/hwloc-2.4.1-djw5rieilo4sypmpsew5rudmesqaw7mp/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-11.1.0/ncurses-6.2-fsd347mkpmp6iezvqzfrn4mqj4wi42be/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-11.1.0/libxml2-2.9.10-rjlorqqgjthe6pheei3mbug73tqdjy74/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-11.1.0/xz-5.2.5-oxdrliw6ak4a54igymkcim5l7w2gcmx2/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-11.1.0/libiconv-1.16-dqvkzxma2htfkms66pdqtntndl7gqpzf/bin
/opt/spack/20210902/opt/spack/linux-ubuntu18.04-x86_64/gcc-7.5.0/gcc-11.1.0-5ikoznknx7aaqakigpo7nriui22lrle5/bin
/opt/vampir/9.3.0/bin
/opt/matlab/R2016a/bin
/opt/ddt/5.0.1/bin
/opt/spack/current/bin
/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin

通过 Fabric 的 SSH:

/usr/local/sbin
/usr/local/bin
/usr/sbin
/usr/bin
/sbin
/bin
/usr/games
/usr/local/games
/snap/bin

我找到了解决方案: 我必须 运行 source /etc/profile 使用 fabric 以获得正确的路径。

通过阅读发现: https://www.gnu.org/software/bash/manual/bash.html#Bash-Startup-Files