文件 ... 不在与主机共享的文件夹中,主机无法打开

The File ... is not in a folder shared with the host and cannot be opened by the host

我想使用 cmd 在 VM 中打开我的 Python 文件。当我执行它时,它总是显示这些消息:文件 ... 不在与主机共享的文件夹中,主机无法打开。

我该如何解决?

你没有提供很多细节。在没有共享文件夹的情况下,如果您已完全设置 ssh 密钥访问权限,则可以使用 scpssh 来实现。根据需要将 {mcs["user"]}@{host}.local 替换为您的用户名和 VM 名称。将 ubuntu.py 替换为您的 python 文件

scp ubuntu.py {mcs["user"]}@{host}.local:. 
ssh {mcs["user"]}@{host}.local python3 ubuntu.py