×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

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

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

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

(OP)
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:

CODE --> 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):

CODE --> 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!



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

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

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

(OP)
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!

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

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%

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

(OP)
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 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources