0

The Abaqus that I run has a pre-installed library (numpy) which has version 1.6.2 This is the only pre-installed module which is present as an "addon" for Abaqus (other than the native Abaqus CAE libraries).

I want to be able to run a python script, executed with abaqus cae nogui=makro.py, so that I can have access to scipy as well. I am doing all this in a very strict environment (no moving around of folders at installation directories)

I have tried the following:

import sys
sys.path.insert(0, '/opt/gcdistro/app/anaconda/2.7/lib/python2.7/site-packages')

import numpy
print(str(numpy.__path__) + ' --- ' + str(numpy.__version__))
sys.stdout.flush()

import scipy
print(str(scipy.__path__) + ' --- ' + str(scipy.__version__))
sys.stdout.flush()
from scipy.optimize import curve_fit

So when I add the above to my script 2 things happen:

  1. The import scipy line runs without any problem which means I have successfully imported the module to the Abaqus Python environment.

  2. from scipy.optimize import curve_fit throws the following ImportError: ImportError: numpy.core.multiarray failed to import

Now, the ImportError has to do with the Abaqus environment having an old verison of numpy.

My output:

['/opt/gcdistro/app/abaqus/6.14-5/6.14-5/tools/SMApy/python2.7/lib/python2.7/site-packages/numpy'] --- 1.6.2
['/opt/gcdistro/app/anaconda/2.7/lib/python2.7/site-packages/scipy'] --- 0.16.0

The strange thing here is that even though I inserted the path to the Anaconda site-packages which contains compatible versions of numpy and scipy it only successfully imported scipy from there. The old numpy version that Abaqus wants to use couldn't be "overwritten" with the newer numpy version which is contained in the site-packages directory.

How can I "force" the usage of the Anaconda numpy instead of the Abaqus numpy?

Since I am not a super-user I am unable to alter anything outside of my home folder.

DjungelJarl
  • 21
  • 1
  • 9
  • why don't you call the python from anaconda to run your script or program ?! – e-nouri Aug 09 '16 at 08:42
  • @e-nouri Because I need to call it using `abaqus cae nogui=makro.py` since otherwise I am unable to use the abaqus-related functions and imports used when creating the model database. Since I am changing the model database each run I need to be able to interact with Abaqus CAE in my script. These functions are not callable outside of the Abaqus environment due to licensing issues. – DjungelJarl Aug 09 '16 at 08:57
  • abaqus cae certainly does not by default preload numpy. It doesn't even preload its own modules. I think you need to discuss the matter with your sys admin. – agentp Aug 09 '16 at 12:47
  • @agentp Sorry what I meant is that when I import numpy it takes the one residing in the abaqus directory no matter if I wipe the sys.path and add another directory. Even when importing numpy with a different name with imp.load_source from a specific directory it still takes the abaqus one for some reason instead of the one pointing to. – DjungelJarl Aug 10 '16 at 08:13
  • maybe some of this : http://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path is useful. (If you find a solution that works with abaqus be sure to post it here as an answer) – agentp Aug 10 '16 at 15:32
  • @agentp I have tried both inserting a path in sys.path and loading with imp as well as the other options they discuss there. Unfortunately it seems as if the Abaqus kernel process (which is required to be the running python process in order to use some abaqus related libraries) first looks at some other place for libraries before it looks in the path. I've also tried exporting with 'export PYTHONPATH=/path/to/all/libraries/'. The mentioned solutions work when invoking with 'abaqus python script.py' but not with 'abaqus cae nogui=script.py', and the 'abauqs python,' doesn't allow abaqus imports – DjungelJarl Aug 12 '16 at 07:15

0 Answers0