问题
我在使用python的subprocess模块调用shell脚本时出现:spark-sql: command not found
没有找到的问题。
解决
按照网上的思路是去/etc/profile
配置文件里配置信息,然后我进入配置文件查看:vim /etc/profile
发现SPARK_HOME和PATH已经配置了,但是仍然出现该问题。所以猜想是配置文件没有生效的问题,所以在命令前加上:
source /etc/profile
这样的话问题就解决了:
subprocess.call("source /etc/profile; bash /home/tmp/train_data.sh", shell=True)