'How to run a python script with a python script in Linux [duplicate]

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?

I'm using zorin os 16.1 (Ubuntu)



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1