Search code examples
pythonsubprocessabaqus

Executing command line program (Abaqus-python script) from python script


I am trying to run an Abaqus-python script file from another python script executed in Spyder (python 3.7, windows 10).

If I run the following command in CMD abaqus cae -noGUI model.py the code executes as expected. However, if I try to run cp = subprocess.run('abaqus cae -noGUI model.py',shell=True) I don't get any output. Below is what is returned in cp.

enter image description here

Notes:

  1. The Abaqus-python file I am trying to run is in the same folder as the python script I have.
  2. I have tried various sp.call, sp.run, os.systems in different string and list formats.
  3. "C:\Abaqus\Commands" and "C:\SIMULIA\Commands" are both in my PATH environment variable.
  4. I think the -noGUI call is important to the problem. I can't seem to find others on SO with this issue.

Solution

  • After a fair amount of digging, I think the issue is that the PATH for my python install is done thought Anaconda so I have a different path this vs CMD. I fixed this by adding the full Abaqus location to the command. See below.

    subprocess.call(r'C:\SIMULIA\Commands\abaqus job=Job-1 ask_delete=OFF interactive', shell=True)