[英]How to run a python program with wscript?
I am trying to run a python program with an anaconda environment (or just a python with some version) through wscript, which will be placed in a batch file, so I can run the program by just double clicking the batch file.我正在尝试通过 wscript 运行具有 anaconda 环境(或仅具有某些版本的 python)的 python 程序,该程序将放置在批处理文件中,因此我只需双击批处理文件即可运行该程序。
here is the code这是代码
Set WinScriptHost = WScript.CreateObject("WScript.Shell")
WinScript.Run "C:\anaconda3\envs\card_player\python.exe C:\projects\card_player\auto_play.py"
Set WinScriptHost = Nothing
I have no idea why it is not working, meanwhile, run the python is perfectly working by我不知道为什么它不起作用,同时,运行 python 完全可以通过
python c:\projects\card_player\auto_play.py
in the console.在控制台中。
What did I wrong?我做错了什么? A console pops up and disappears right away after I click the batch file...
单击批处理文件后,控制台会立即弹出并消失...
Replace WinScript.Run "C:\anaconda3\envs\card_player\python.exe C:\projects\card_player\auto_play.py" by the following line:将 WinScript.Run "C:\anaconda3\envs\card_player\python.exe C:\projects\card_player\auto_play.py" 替换为以下行:
WinScriptHost.Run("C:\anaconda3\envs\card_player\python.exe C:\projects\card_player\auto_play.py")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.