简体   繁体   English

使用 python2 脚本启动 python3 脚本

[英]Launching python3 script using a python2 script

is there a way to launch a script running on python3 via a python2 script.有没有办法通过 python2 脚本启动在 python3 上运行的脚本。

To explain briefly I need to start the python3 script when starting the python2 script.简单解释一下我需要在启动python2脚本的时候启动python3脚本。

Python3 script is a video stream server (using Flask) and have to run simultaneously from the python2 script (not python3 script first and then python2 script). Python3 脚本是一个视频 stream 服务器(使用 Flask),必须同时从 python2 脚本运行(不是先运行 python3 脚本,然后再运行 python2 脚本)。

The ideal would be to get a function in the python2 script which "open a cmd window and write" it in: python3 script_python3.py理想的情况是在 python2 脚本中获取 function ,该脚本“打开 cmd window 并将其写入”:python3 script_python3.py

  1. create command in bash file.在 bash 文件中创建命令。 command is to run script_python3.py, ex: python script_python3.py命令是运行 script_python3.py,例如:python script_python3.py
  2. then from python2 file, run the.bash file.然后从 python2 文件中,运行 .bash 文件。 ex: import os os.popen('sh /scripts/my_bash.sh')例如:导入操作系统 os.popen('sh /scripts/my_bash.sh')

You could use something like explained in this answer .您可以使用此答案中解释的内容。

That use case of that question is a bit different, but the answer should work.该问题的用例有点不同,但答案应该有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM