I've reduced the problem I am having to this. Here is the contents of my python script tmp.py:
import numpy
print "Imported numpy!"
If I call the python script directly at the command line
$ python tmp.py
It successfully imports numpy and prints the print statement.
Here is the contents of my bash script test.sh:
#!/bin/bash
echo "PYTHONPATH:: $PYTHONPATH"
echo "PATH:: $PATH"
echo "LD_LIBRARY_PATH:: $LD_LIBRARY_PATH"
pyver=`which python`
echo "Using python version $pyver"
python tmp.py
If I call this script at the command line,
$ ./test.sh
I get the following error:
Traceback (most recent call last):
File "tmp.py", line 1, in <module>
import numpy
File "/home/alex/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/__init__.py", line 148, in <module>
import add_newdocs
File "/home/alex/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "/home/alex/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/__init__.py", line 13, in <module>
from polynomial import *
File "/home/alex/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 17, in <module>
from numpy.linalg import eigvals, lstsq
File "/home/alex/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 48, in <module>
from linalg import *
File "/home/alex/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 23, in <module>
from numpy.linalg import lapack_lite
ImportError: libmkl_gf_lp64.so: cannot open shared object file: No such file or directory
I have checked that the results of echo $PYTHONPATH, echo $PATH, echo $LD_LIBRARY_PATH and which python all return the same whether called within the bash script or at the command line.
I have no idea what is going on!
$ ls -Fal /bin/bashoutput?$ . ./test.shor$ source ./test.shinstead of$ ./test.sh?tmp.py$ source ./tesh.shWhy is this?