从bash运行Python脚本:找不到命令错误

Vig*_*esh 3 python linux bash shell

我找不到命令错误.0和$ filestem是两个args,我在脚本中有以下内容.当我执行脚本时,我找不到命令.

echo -e "Enter the file stem name"
read filestem
python gen_par_final.py 0 $filestem
Run Code Online (Sandbox Code Playgroud)

输入文件,python脚本和bash脚本都在同一个文件夹中.python脚本在命令promt中工作,但不在脚本内部.是否有任何路径可以设置或解决问题?

Sag*_*she 5

这可行

  1. 将其插入文件#! /usr/bin/Python顶部gen_par_final.py.
    (通常/usr/bin/python你需要查看它的资金情况P)

  2. gen_par_final.py可执行文件
    $ chmod +x gen_par_final.py

  3. 编辑shell脚本.

    echo -e "Enter the file stem name"
    read filestem
    ./gen_par_final.py 0 $filestem