简体   繁体   English

使用它的 Python3 文件在本地机器上通过 SSHFS 挂载虚拟环境不起作用

[英]Mounting a virtual environment via SSHFS on local machine using it's Python3 file not working

So I have mounted a part of a development server which hold a virtual environment that is used for development testing.因此,我安装了开发服务器的一部分,其中包含用于开发测试的虚拟环境。 The reason for this is to get access to the installed packages such as Django-rest-framework and Django itself and not having it set up locally (to be sure to use the same version as the development server has).这样做的原因是要访问已安装的包,例如 Django-rest-framework 和 Django 本身,而不是在本地设置它(确保使用与开发服务器相同的版本)。 I know that it's perhaps better to use Docker for this, but that's not the case right now.我知道为此使用 Docker 可能更好,但现在情况并非如此。

The way I've done it is installing SSHFS via an external brew (as it's no longer supported in the brew core) - via this link https://github.com/gromgit/homebrew-fuse我的做法是通过外部 brew 安装 SSHFS(因为 brew 核心不再支持它)-通过此链接https://github.com/gromgit/homebrew-fuse

After that I've run this command in the terminal to via SSH mount the specific part of the development server that holds the virtual enviornment:之后,我在终端中运行此命令以通过 SSH 挂载包含虚拟环境的开发服务器的特定部分:

sshfs -o ssh_command='ssh -i /Users/myusername/.ssh/id_rsa' myusername@servername:/home/myusername/projectname/env/bin ~/mnt/projectname

It works fine and I have it mounted on my local disk in mnt/projectname.它工作正常,我将它安装在本地磁盘的 mnt/projectname 中。

Now I go into VSCode and go into the folder and select the file called "python3" as my interpreter (which I should, right?).现在我进入 VSCode 并进入文件夹并选择名为“python3”的文件作为我的解释器(我应该这样做,对吗?)。 However, this file is just an alias, being 16 bytes in size.但是,该文件只是一个别名,大小为 16 字节。 I suspect something is wrong here, but I'm not sure on how to fix it.我怀疑这里有问题,但我不确定如何解决。 Can someone maybe take a look and give some input?有人可以看看并提供一些意见吗? I'll attach a screenshot of the mounted directory.我将附上挂载目录的屏幕截图。

Screenshot of virtualenv directory mounted on local machine安装在本地机器上的 virtualenv 目录的屏幕截图

该问题的解决方案是使用 VSCode 扩展远程 - SSH 并直接在远程位置运行 VSCode,并从那里能够访问虚拟环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM