Os.system Not Working, But Typing The Same Thing Into The Command Prompt Works
I am trying to run python abaqus through the command prompt using os.system('abaqus CAE noGUI=ODBMechens') It doesn't seem to run anything, but if I go to the command prompt myse
Solution 1:
try using the subprocess module (it's newer) instead: for example,
subprocess.call(["ls", "-l"])
and in your example, it would be:
subprocess.call('abaqus CAE noGUI=ODBMechens')
More info on the difference between subprocess module and using os.system call:
Solution 2:
You should add before your code
import os
import subprocess
try:
os.environ.pop('PYTHONIOENCODING')
except KeyError:
pass
And then:
cmd = subprocess.Popen('abaqus CAE noGUI=ODBMechens',cwd=jobPath, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, shell=True).communicate()[0]
Variable cmd contains your output. I found that this way it works.
Post a Comment for "Os.system Not Working, But Typing The Same Thing Into The Command Prompt Works"