E_J E_J - 1 month ago 7
Python Question

python3.5 not opening a .py file

Hello im having trouble opening a .py file using processes call in python 3.5.
ive have opened other files for example a text file using this method but with .py files it seems to just skip the command. Here is my code :

import subprocess
subprocess.call(['C:\\Users\\Edvin\\AppData\\Local\\Programs\\Python\\Python35-32\\pythonw.exe', 'C:\\Users\\Edvin\\Desktop\\test.py'])
print ("done")


There is no error it is simply doing >>> then >>>done when test.py isnt even open. Is this even possible for python to open another python file?

the context of test.py is:

print("hello world")


reply=input("Say hello!")

Answer

try to use run instead of call.

subprocess.run(['C:\\Users\\Edvin\\AppData\\Local\\Programs\\Python\\Python35-32\\pythonw.exe', 'C:\\Users\\Edvin\\Desktop\\test.py'])