interacting python and abaqus
<p>I need for an algorithm to update an input file, I found out that I can modify a .py file and run it in abaqus.</p>

<p>But because of the process is necessary to automatize, I'm trying to open a script and run it in abaqus </p>

<p>I tried this: os.system('abaqus cae script=C:\Users\Samuel\abaqus-1\script1.py')</p>

<pre><code>import os
import subprocess


HERE = os.path.dirname(os.path.abspath(__file__))


def create_script(name):
    path = os.path.join(HERE, 'abaqus-1', name)
    return path


name = 'script1.py'
script_path = create_script(name)
print (script_path)


args = ['abaqus', 'cae', 'script={0}'.format(script_path)]
print (args)
p = subprocess.Popen(args) # Success!
print(p.communicate()) 
</code></pre>

<p>this works on the cmd dos windows but doesnât work on python, if anyone can help me I would appreciate it</p>

<p>error </p>

<pre><code>['abaqus', 'cae', 'script=C:\\Users\\Samuel\\abaqus-1\\script1.py']
Traceback (most recent call last):
  File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  File "C:\Users\Samuel\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
    execfile(filename, namespace)
  File "C:\Users\Samuel\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)
  File "C:/Users/Samuel/prueba control.py", line 28, in &lt;module&gt;
    p = subprocess.Popen(args) # Success!
  File "C:\Users\Samuel\Anaconda3\lib\subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "C:\Users\Samuel\Anaconda3\lib\subprocess.py", line 1224, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
</code></pre>

<p>Maybe this sentence is incorrect - </p>

<pre><code>os.system('abaqus cae script=C:\Users\Samuel\abaqus-1\script1.py')
</code></pre>

<p>You have to run a python script in Abaqus using the command </p>

<pre><code>abaqus cae noGUI=nameOfScript.py
</code></pre>

<p>So in your case, </p>

<pre><code>os.system('abaqus cae noGUI=C:\\Users\\Samuel\\abaqus-1\\script1.py')
</code></pre>

<p>I am not sure about the '\' since I usually open abaqus in the same folder where I have my python scripts. </p>

python abaqus