Shell脚本:获取python:未找到命令错误
当我从shell脚本调用Python脚本时,它运行良好Shell脚本:获取python:未找到命令错误,python,bash,shell,Python,Bash,Shell,当我从shell脚本调用Python脚本时,它运行良好 python script.py 但是,在我从Gerrit提取了相同的脚本,然后添加了调用Python脚本的代码之后,它给了我以下错误: ./script.sh: line 126: python: command not found 看起来像是路径问题 在终端中使用哪个python,首先找到您的python路径。就我而言,它位于/usr/bin中 $ which python /usr/bin/python 然后在script.sh
python script.py
但是,在我从Gerrit提取了相同的脚本,然后添加了调用Python脚本的代码之后,它给了我以下错误:
./script.sh: line 126: python: command not found
看起来像是路径问题 在终端中使用
哪个python
,首先找到您的python路径。就我而言,它位于/usr/bin中
$ which python
/usr/bin/python
然后在script.sh中添加python path to path变量,例如,在调用python之前,将以下行放在任意位置
PATH+=:/usr/bin
显然,script.sh内部的路径与shell脚本内部的路径不同,后者工作良好。修复script.sh中的路径,或者通过abs路径调用python。