无法执行 "python": 没有那个文件或目录

couldn't execute "python": no such file or directory

我正在尝试从 tcl 脚本执行 python 但我收到消息错误 "couldn't execute "python": no such file or directory"

这是我的代码: test.py

print('hello')

exec.tcl

set out [exec python test.py]
puts $out

并且在 Windows PowerShell 中我使用这个命令:

tclsh exec.tcl 

你能帮我解决这个错误吗?

根据您的 Python 版本,它可能使用 py 作为命令。您应该尝试使用 'py' 而不是 'python'。

更多信息: Python Launcher for Windows (Python Docs)