Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to run a python script with a python script in Linux

I am running in Linux and I need to open another python script with a python script and in windows it was as easy as

import os
os.startfile(dir)

but now im in Linux it gives me

Traceback (most recent call last):
  File "/home/dev/PycharmProjects/pythonProject/vpn.py", line 1, in <module>
    os.startfile('main.py')
AttributeError: module 'os' has no attribute 'startfile'

what do I use to run files in Linux?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I’m using zorin os 16.1 (Ubuntu)

>Solution :

Personally, I prefer to use os.system('python main.py'), since it is the same as just running the command python main.py from your command line

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading