簡體   English   中英

通過cygwin運行時找不到Python os.system“啟動”命令

[英]Python os.system “start” command not found while running through cygwin

我在C:\\ Python27中安裝了python。 另外,我已經用python軟件包安裝了cygwin。 在cygwin64終端中,當我執行“哪個python”時,它會給出/ usr / bin / python。

現在從命令提示符處運行一個簡單的python腳本時:

#!/usr/bin/env/python

import os
os.system("start notepad.exe")

記事本開始運行。

但是從Cygwin64終端執行python run.py時會引發錯誤: “ sh:start:找不到命令”

可能是什么原因? 我已經通過cygwin終端通過chmod + x run.py使python腳本可執行。 但這沒有幫助。

謝謝你的支持。

這不是Python問題,而是與Cygwin相關的問題。 Cygwin本身沒有start命令。 如果我沒記錯的話,那是cmd.exe

當您在Cygwin中時,您基本上是在Unix環境中。 那意味着

os.system("notepad.exe")

應該足夠了。 前提條件是正確設置了PATH環境,並包括notepad.exe所在的Windows目錄; 例如/c/windows/c/winnt

您可以通過啟動Cygwin窗口(使用Bash進程)並鍵入notepad.exe 如果開始,那很好。 類似地,在Bash中,如果您鍵入start notepad.exe則(再次)外殼將顯示: start: command not found

您無需鍵入開始。

這可以通過以下方式完成。

導入操作系統os.system(“ Notepad.exe”)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM