问题
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:
The
import scipy
line runs without any problem which means I have successfully imported the module to the Abaqus Python environment.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.
来源:https://stackoverflow.com/questions/38845741/python-overwrite-import-of-numpy-from-abaqus-with-different-version-of-numpy