bash - ImportError when calling python script via a shell script -


i've reduced problem having this. here contents of python script tmp.py:

    import numpy     print "imported numpy!" 

if call python script directly @ command line

    $ python tmp.py 

it imports numpy , prints print statement.

here contents of 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 call script @ command line,

    $ ./test.sh 

i 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>         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>         polynomial import *       file "/home/alex/enthought/canopy_64bit/user/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 17, in <module>         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>         linalg import *       file "/home/alex/enthought/canopy_64bit/user/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 23, in <module>         numpy.linalg import lapack_lite     importerror: libmkl_gf_lp64.so: cannot open shared object file: no such file or directory 

i have checked results of echo $pythonpath, echo $path, echo $ld_library_path , which python return same whether called within bash script or @ command line.

i have no idea going on!

i had similar problem. turned out in bash script running python script different version of python on command line (my env set virtualenv on python 2.7 calling script python3 bash script).

there nothing in snippets indicating case worth checking make sure python versions match up.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -