0

I want to execute three python script that I have developed. I found one doubt, how could I do it using a python script?

I want to convert it into a .exe, because our solution is thought to be executed in machines without python installed so having an unique script would be helpful.

Edit: I don't know the cause of the closure of my old question, I know how to use pyinstaller, my question was how can I execute 3 python using a python script or if it is possible. Please, if you are gonna close a question be sure that the question is duplicated, you are unranking me in the forum.

Any suggestion? Thanks!

  • 2
    So can't you just use one main program that runs the scripts, and then use pyinstaller? – Heikura May 25 '21 at 08:26
  • Can you please show how these 3 python scripts are related and run/used? It's not clear what's the problem, why can't you just have 1 main .py file that calls these 3 other python scripts? – Gino Mempin May 25 '21 at 10:26
  • 1
    Does this answer your question? [How to build multiple .py files into a single executable file using pyinstaller?](https://stackoverflow.com/questions/51455765/how-to-build-multiple-py-files-into-a-single-executable-file-using-pyinstaller) – Gino Mempin May 25 '21 at 10:33

2 Answers2

0

If you have three separate python scripts, I assume that you could just create, for example, one main.py script that calls your scripts in order:

Example main.py:

import script1
import script2
import script3

def main():
   script1()
   script2()
   script3()
   # Or you might have some kind of starting function e.g. script.starting_function()

if __name__ == "__main__":
   main()

Then just convert the python files to an .exe-file with pyinstaller.

Or did you mean something different with your question?

Heikura
  • 1,009
  • 3
  • 13
  • 27
0

If you want to run them in separate command windows with different interpreters, try the following:

import os
import sys

file_name = "testfile.py"
os.system(sys.executable + file_name)

or if you want to change folders aswell:

import os
import sys

file_path = "C:/Your_folder/"
# For Windows/Linux compatibility: file_path = "C:" + os.sep + "Your_folder" + os.sep
file_name = "myfile.py"

os.system("cd " + file_path + " & " + sys.executable + " " + file_name )
mnikley
  • 1,625
  • 1
  • 8
  • 21