Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations MintJulep on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Abaqus python through command line: Error message "ImportError: No module named ******"

Status
Not open for further replies.

dfgsdfgfd

Mechanical
Sep 30, 2015
37
Hi everyone,

I'm trying to run Abaqus through a command line with abaqus python d:\file.py. However, I receive the following error message:

Python:
Traceback (most recent call last):
	File "file.py", line 1, in <module>
		from part import *
	File "SMAPython\SMAPytLibPy.m\src\site.py", line 120, in _numpyHook 
		"""Append ./build/lib.<platform> in case we're running in the build dir
ImportError: No module named part

file.py looks as follows (and I receive the same error for all of the Abaqus-modules I want to import; it works for other, standard modules):
Python:
from part import *
from material import *
from section import *
from assembly import *
from step import *
from interaction import *
from load import *
...

Unfortunately, I couldn't find any solution online and would really appreciate your help. Thank you very much!



 
Replies continue below

Recommended for you

You run the script from the command line, so it has no access to CAE related module, methods or objects.

If you need that, you may run the script through CAE but without starting the GUI. Should be something like that:
abaqus cae noGui=file.py
 
Thanks so much for your quick response - it works like a charm!
Another quick question: When I have the batch file, e.g. run.bat, with content abaqus cae noGui=file.py in the same directory like the file.py, it can't find it ("abaqus error: the following file(s) could not be located: file.py"). It only works if I specify the directory, like in: abaqus cae noGui=C:\file.py. Is there a way to set it to the same location the batch file is in?

Thanks a lot!
 
A batch file is executed in a Windows default directory, not locally. Place the following command at beginning of you batch file, to redirect the execution directory.

set WORKING_DIRECTORY=%cd%
 
I also added cd %~dp0 in front of the line you mentioned, which reads the actual location of the .bat file. Now it seems to work. Thanks very much!

Code:
cd %~dp0
set WORKING_DIRECTORY=%cd%
abaqus cae noGui=file.py
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor