我已经减少了我遇到的问题。这是我的python脚本的内容tmp.py
:
import numpy
print "Imported numpy!"
如果我直接在命令行调用 python 脚本
$ python tmp.py
它成功导入 numpy 并打印 print 语句。
这是我的 bash 脚本的内容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
如果我在命令行调用这个脚本,
$ ./test.sh
我收到以下错误:
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
我已经检查过,无论是在 bash 脚本中还是在命令行中调用的结果,都返回相同echo $PYTHONPATH
的结果。echo $PATH
echo $LD_LIBRARY_PATH
which python
我不知道发生了什么事!