Reputation: 720
I have not been successful at importing numpy
package to ABAQUS Python environment from previous discussions on this similar problem.
I am working on Microsoft Windows 7 (64-bit). I have installed ABAQUS 6.10. And by typing the command abaqus python
in MS-DOS prompt I figured that ABAQUS 6.10 uses Python 2.6.2 version. For an important reason, my python script file needs to use the array
function available in the numpy
package. I undertook the following steps based on previous discussions:
Python 2.6.2 installation:
C:\Python26\
(I already had Python 2.7.6 installed in folder C:\Python27\
)PATH
variable to C:\Python26\;
(previously it was C:\Python27\
)PYTHONPATH
variable to C:\Python26\Lib\site-packages\
(previously it was C:\Python27\
)python
in MS-DOS prompt.Numpy installation for Python 2.6.2:
numpy-1.3.0-win32-superpack-python2.6
from Sourceforge.net- NumPy 1.3.0 in C:\Python26\Lib\site-packages folder.python
in MS-DOS prompt.numpy
successfully using the command import numpy
in python environment.Numpy installation for ABAQUS 6.10:
C:\Python26\Lib\site-packages\
and pasted to D:\SIMULIA\Abaqus\6.10-1\Python\Lib\site-packages
, which is the python modules folder for ABAQUS. Please note I have installed ABAQUS 6.10 in D: drive.from numpy import *
and saved it in the desktop.myScript.py
.abaqus cae noGUI=myScript.py
and I got the following errors:Abaqus License Manager checked out the following license(s): "cae" release 6.10 from 127.0.0.1 <2010 out of 2011 licenses remain available>. ImportError: DLL load failed: %1 is not a valid Win32 application. File "myScript.py", line 4, in <module> from numpy import array File "C:\Python26\Lib\site-packages\numpy\__init__.py", line 130, in <module> import add_newdocs File "C:\Python26\Lib\site-packages\numpy\add_newdocs.py", line 9, in <module> from lib import add_newdoc File "C:\Python26\Lib\site-packages\numpy\lib\__init__.py", line 4, in <module> from type_check import * File "C:\Python26\Lib\site-packages\numpy\lib\type_check.py", line 8, in <module> import numpy.core.numeric as _nx File "C:\Python26\Lib\site-packages\numpy\core\__init__.py", line 5, in <module> import multiarray Abaqus Error: cae exited with an error.
Note: I installed Python 2.6.2 32-bit because the numpy available for 64-bit was showing a warning that it is unstable and would subsequently crash.
My basic question is: "How can I successfully import numpy
package into ABAQUS environment?"
Upvotes: 2
Views: 2921
Reputation: 86
Honestly, the 32-bit version of numpy will not work with a 64-bit version of Python. Therefore, the error is quite expected. Even if Abaqus were to use a 32-bit version, I would strongly advise not to copy and paste the directory of the library.
dim_voly answer is an easy way to get around this problem, but here are some instructions if you really want to use numpy inside Abaqus
This link explains quite clearly how to install numpy. You will need to include the Abaqus Python directory in the PATH environmental variable. Once pip
is installed, it should be easy to install numpy and any other library you need.
I am currently using Abaqus 6.13 which already comes installed with numpy. Thus, upgrading your software can also be a viable solution.
Hope this helps
Upvotes: 2
Reputation: 541
I had trouble importing anything into the Abaqus python environment. The workaround I used was to generate the .py script using a main .py script. So all the calculations are done and pasted in as text into a template .py script. Then later the main script calls abaqus to run the python script.
I generally found that the python version within Abaqus is behind the mainstream python version and doing anything remotely out of the ordinary doesn't work as it depends on Simulia to update things. I use too many custom packages as well.
In any case you end up wanting a master python script to set up high level things like folders and reading in data from tables. And if you're running a script to build a model, I don't doubt that you're doing a parametric study so your loops for that can be in the main script.
What also sometimes works for passing data into the abaqus .py file is setting up a struct or class and saving it using pickle
. As far as I recall pickle works and is importable as long as the class does not contain any custom imports.
Upvotes: 1