I am trying to call a python file "hello.py" from within the python interpreter with subprocess. But I am unable to resolve this error. [Python 3.4.1].
import subprocess
subprocess.call(['hello.py', 'htmlfilename.htm'])
Traceback (most recent call last):
File "<pyshell#42>", line 1, in <module>
subprocess.call(['hello.py', 'htmlfilename.htm'])
File "C:\Python34\lib\subprocess.py", line 537, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Python34\lib\subprocess.py", line 858, in __init__
restore_signals, start_new_session)
File "C:\Python34\lib\subprocess.py", line 1111, in _execute_child
startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application
Also is there any alternate way to "call a python script with arguments" other than using subprocess? Thanks in advance.
I also experienced this error. Then I install Visual Studio 2015 Redistribution package via this link. Problem solved:). Try it, before doing further modifications.
I got the same error while I forgot to use
shell=True
in thesubprocess.call
.Python installers usually register .py files with the system. If you run the shell explicitly, it works:
You can check your file associations on the command line with
The error is pretty clear. The file
hello.py
is not an executable file. You need to specify the executable:You'll need
python.exe
to be visible on the search path, or you could pass the full path to the executable file that is running the calling script: