I found this interesting solution for executing python script within another python script, here. I am having difficulty using the module as it does not run the script correctly.
import subprocess
proc = subprocess.Popen(['python', 'test.py', ''], shell=True)
print(proc.pid)
Content of test.py
:
print("I am inside test.py")
I am expecting to see the print output I am inside test.py
but nothing gets printed although I see that Popen
returns a pid. I am not sure if it has something to do with PyCharm under Ubuntu. I tried this under Windows and I still have the same issue: I am inside test.py
will not be printed.
Could someone kindly help me out?