【发布时间】:2021-03-18 21:08:21
【问题描述】:
我在 Visual Studio Code (2019) 中运行 Cygwin 终端,我尝试运行 hello.sh 和 hello.py 文件,但终端中没有打印任何内容。也没有错误信息。我还尝试在 Visual Studio 之外打开 Cygwin 终端,也没有打印出来。
但是,我在 venv 目录中从 Pycharm 创建了相同的文件,并将这些文件复制到了我的 Cygwin 目录中——它工作正常。
hello.py 文件中的代码:
print("hello world")
hello.sh 文件中的代码:
echo hello world
我在上述所有终端中使用相同的命令运行这些文件:
./hello.sh
python hello.py
当我使用从 Pycharm 生成和复制的 hello.py 和 hello.sh 文件时的输出:
hello world
否则从 Cygwin 运行这两个文件时什么也不会发生。
我想知道这是怎么发生的,以及如何生成可以直接在 VS Studio 中工作的 .py 文件和 .sh。
我看到其他线程在运行 .sh 文件时提到“找不到命令”错误。这不是我的情况,因为不会打印出任何错误。
谢谢!
【问题讨论】:
-
VS在哪里寻找要执行的程序?我怀疑它是否知道 Cygwin,并且知道需要运行 bash 或 python 的 cygwin 版本
-
也许第一步是运行类似
diff hello.py pycharm/hello.py的东西 -
@matzeri 您好,我已将 VS 代码配置为使用 Cygwin 作为集成终端。
-
@Bec Zhao - 进展如何?只需检查一下提供的信息是否有帮助。
标签: python shell visual-studio-code terminal cygwin