2

I have a pyqt5 project which has a button. This button when clicks installs a windows service by using below command:

os.system('python myservice.py install')

os.system('python myservice.py start')

After this, a windows service myservice is installed and started. This is just one of the feature of whole application. I have now converted the project into app.exe using pyinstaller. Then using inno compiler, I have created a setup file.

I am installing the application on another system on which python is not installed. pyinstaller while converting the python scripts to exe, also binds the current python interpreter and installed packages so running the application on another pc works perfectly fine. But when I clicking on the install service buttons, its not working because it runs the command as python myservice.py install and because python is not installed thus it gives error.

I also checked this by typing python on cmd and it didnt showed anything. Is there any possibility where I can run python command without installing python on another pc. Thanks

2
  • See this question: stackoverflow.com/questions/44508677/…. I suppose you could pass values in globals or locals. I wouldn't normally recommend using exec but it does work. See this question: stackoverflow.com/questions/60253999/… Commented Sep 12, 2020 at 12:18
  • @PeterWood I want to run this command using pyinstaller python myscript.py install. I can do this exec(open('opc_client_service.pyc').read()) but I am unable to understand how do I pass install to it. Commented Sep 15, 2020 at 2:47

1 Answer 1

1

first of all I would recommend to use subprocess.call instead of os.system

second, if you need to run another python code it is just fine to create another executable from myservice.py and then run myservice.exe install

alternative would be to have one code that generates service and UI in one compiled exe. But I do not think it is a good approach.

Sign up to request clarification or add additional context in comments.

3 Comments

So running this command myservice.exe install will install the service.?
I would expect that software generated by pyinstaller will work the same way as py files themselves. So you need to create exe from myservice.py
@SAndrew, you need to check how myservice.py is created. This might be an arguments issue, since when you use command with python your arguments install is third one, while with .exe is second.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.